我在控制台中遇到错误。你能帮我修一下吗?
我已经包含了requirejs和必要的主干库。
JSBin Demo
我的代码
require.config({
paths : {
backbone : '//jashkenas.github.io/backbone/backbone-min.js',
underscore : '//jashkenas.github.io/underscore/underscore-min.js',
jquery : '//code.jquery.com/jquery-2.1.1.min.js',
marionette : 'http://marionettejs.com/downloads/backbone.marionette.min.js'
},
shim : {
jquery : {
exports : 'jQuery'
},
underscore : {
exports : '_'
},
backbone : {
deps : ['jquery', 'underscore'],
exports : 'Backbone'
},
marionette : {
deps : ['jquery', 'underscore', 'backbone'],
exports : 'Marionette'
}
}
});发布于 2014-09-05 21:25:20
首先,您不需要在html中添加backbone、jquery和其他库的脚本标记,因为您已经使用requirejs api包含了它们。其次,建议您将定义代码放在单个文件中,或者应该为其命名。
更多信息,请查看此处:http://requirejs.org/docs/errors.html#mismatch
确保加载所有通过RequireJS接口调用define()的脚本。不要在HTML语言中手动编写脚本标记来加载在其中有define()调用的脚本。
如果您手动编写HTML script标记,请确保它只包含命名模块、,并且未加载与该文件中的某个模块同名的匿名模块。
https://stackoverflow.com/questions/25686434
复制相似问题