未定義だと言う: printscreenが、それは私が私のフロントエンドがそうのように構築するモジュール化
すべてのコンポーネントは、(HTML フォルダ内の)その
.css
と.js
でそのフォルダを持っています。すべての依存関係ライブラリは
vendor.js
にあります。すべての
.js
コンポーネントのファイルはすべてbundle.js
にコンパイルされます。
- DEV-モードvendor.js:あなたは私上記のコードで見たよう
export default class Five {
constructor() {
console.log('Five');
this.init_PhotoSwipe();
}
init_PhotoSwipe() {
var pswpElement = document.querySelectorAll('.pswp')[0];
var items = [
{
src: 'https://placekitten.com/600/400',
w: 600,
h: 400
},
{
src: 'https://placekitten.com/1200/900',
w: 1200,
h: 900
}
];
// define options (if needed)
var options = {
// optionName: 'option value'
// for example:
index: 0 // start at first slide
};
// Initializes and opens PhotoSwipe
var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
gallery.init();
}
};
const five = new Five();
:私はphotoswipe
ライブラリを初期化
import $ from 'jquery';
import './assets/Swiper-3.3.1/dist/js/swiper.min';
import './assets/twentytwenty/js/jquery.event.move';
import './assets/twentytwenty/js/jquery.twentytwenty';
import './assets/PhotoSwipe/dist/photoswipe';
import './assets/PhotoSwipe/dist/photoswipe-ui-default';
コンポーネントの.js
例ライブラリを初期化するnew PhotoSwipe(...)
ブラウザがエラーに遭遇したと私に語っている:「キャッチされないのReferenceError:PhotoSwipeが定義されていません」:vendor.js
ファイルが含まれているbundle.js
前に、それはPhotoSwipe
を見ることができない理由それは奇妙だ
注意変数。
PhotoSwipeライブラリコード:https://github.com/dimsemenov/PhotoSwipe/blob/master/dist/photoswipe.js
にはどうすればPhotoSwipe機能の新しいインスタンスを初期化することができますか?