【发布时间】:2014-02-20 06:48:26
【问题描述】:
我在将 Imager.js 库添加到 require.js 加载时遇到问题,脚本可以在没有 require.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
当我定义 Imager 时
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',
}
});
});
现在我收到了这个错误
Uncaught TypeError: undefined is not a function
发生了什么事?我如何使用 require 正确添加这个库??
【问题讨论】:
-
Imager在传递参数时排在第二位,但您在define数组中将其导入第三位
标签: javascript requirejs undefined amd