我的App.js
import $ from 'jquery';
import fluidbox from 'fluidbox';
import FluidBoxWpGallery from './modules/FluidBoxWpGallery';
var fluidBoxWpGallery = new FluidBoxWpGallery();
我的FluidBoxWpGallery():
import $ from 'jquery';
class FluidBoxWpGallery {
constructor() {
this.els = $(".gallery a");
this.initFluidGallery();
}
initFluidGallery() {
this.els.each(function() {
$(this).attr('data-fluidbox','');
});
if($('[data-fluidbox]').length>0){
$('[data-fluidbox]').fluidbox();
}
}
}
export default FluidBoxWpGallery;
一切正常...元素获得attr数据流框,但错误在第15/16行。我认为在webpack中
这是控制台中的输出:
App.js?ver=4.9.8:10051 Uncaught TypeError: (0 , _jquery2.default) .
(...).fluidbox is not a function
at FluidBoxWpGallery.initFluidGallery (App.js?ver=4.9.8:10051)
at new FluidBoxWpGallery (App.js?ver=4.9.8:10041)
at Object.<anonymous> (App.js?ver=4.9.8:79)
at __webpack_require__ (App.js?ver=4.9.8:20)
at App.js?ver=4.9.8:40
at App.js?ver=4.9.8:43
感谢您的帮助!