我加入Imager.js庫中的問題require.js負載,腳本工作完美無require.jsRequire.js和Imager.js未定義功能
Main.js
define([
'jquery',
'bootstrap',
'imager',
'video'
],
function($) {
'use strict';
$('.dropdown-toggle').dropdown();
$('#bvideo').magnificPopup({
type: 'inline'
});
videojs('video-cdve', {
'controls': true,
'autoplay': false,
'preload': 'auto',
'width': 'auto',
'height': 'auto'
});
new Imager({
availableWidths: {
320: '320x240',
640: 'large',
1024: 'large_x2',
}
});
});
我得到這個錯誤
Uncaught ReferenceError: Imager is not defined
當我定義成像儀
define([
'jquery',
'bootstrap',
'imager',
'video'
],
function($, Imager) {
'use strict';
$('.dropdown-toggle').dropdown();
$('#bvideo').magnificPopup({
type: 'inline'
});
videojs('video-cdve', {
'controls': true,
'autoplay': false,
'preload': 'auto',
'width': 'auto',
'height': 'auto'
});
new Imager({
availableWidths: {
320: '320x240',
640: 'large',
1024: 'large_x2',
}
});
});
現在我recive這個錯誤
Uncaught TypeError: undefined is not a function
請告訴我happend?我如何正確添加此庫與要求?
define([
'jquery',
'bootstrap',
'imager',
'video'
],
function($, Imager) {
你要綁定Imager
到'bootstrap'
模塊的價值:所以當你做到這一點
'Imager'在傳遞參數時是第二個,但是在您的'define'數組中第三個導入它時 – ashley