做following question我包裹着我的编译自举JS插件文件的AMD模块中,像这样的一些阅读后:使用Twitter的引导与requireJS - 不确定是不是function`
define(['zepto'], function($){ ...Bootstrap pasted here... });
那么这就是我的main.js文件看起来像配置:
require.config({
baseUrl: 'js',
paths: {
'zepto': 'lib/zepto',
'underscore': 'lib/underscore',
'backbone': 'lib/backbone',
'text': 'lib/text',
'bootstrap': 'lib/bootstrap'
},
shim: {
'zepto': {
exports: '$'
},
'underscore': {
exports: '_'
},
'backbone': {
deps: ['zepto', 'underscore'],
exports: 'Backbone'
}
}
});
require([
'app',
'zepto',
'underscore',
'backbone',
'bootstrap'
],
function(App){
//start the app
App.initialize();
});
但在控制台中我得到的bootstrap.js以下错误文件:
Uncaught TypeError: undefined is not a function
看来$并没有被定义,即使它被传递到模块中。完整包装的引导程序模块可用here。
我正在使用应该与Bootstrap兼容的zepto,并且正在从垫片中导出$,所以看不到为什么这对我不起作用。