@H_404_1@在最小的应用程序中使用RequireJS和Backbone,我总是得到
@H_404_1@
https://assets.site44.com/admin/ @H_404_1@我在index.html中包含jQuery,下划线,主干,因为我想缩短每个视图/模型中的define()样板. @H_404_1@https://assets.site44.com/admin/js/main.js由 @H_404_1@
Mismatched anonymous define() module @H_404_1@谢谢
Uncaught Error: Mismatched anonymous define() module
@H_404_1@即使该应用程序继续工作.这里是:https://assets.site44.com/admin/ @H_404_1@我在index.html中包含jQuery,下划线,主干,因为我想缩短每个视图/模型中的define()样板. @H_404_1@https://assets.site44.com/admin/js/main.js由 @H_404_1@
var l = console.log.bind(console)
var app
//l("AA")
require.config({
paths: {
// Major libraries
/*jquery: 'libs/jquery/jquery-min',underscore: 'libs/underscore/underscore-min',// https://github.com/amdjs
backbone: 'libs/backbone/backbone-min',// https://github.com/amdjs
*/
// Require.js plugins
text: 'text'
}
})
function initApp() {
console.log("BB")
require([
'views/AppView'
],function(AppView){
l("CC")
app = new AppView()
$("#app").html(app.render())
})
}
$(document).ready(initApp)
@H_404_1@我无法从文档或这个回答的问题中找出问题:Mismatched anonymous define() module @H_404_1@谢谢
最佳答案
@H_404_1@I’m including jQuery,underscore,backbone in index.html,since I want to shorten the define() boilerplate in each view/model.@H_404_1@你不应该.如果您google “Uncaught Error: Mismatched anonymous define() module”,您会注意到最上面的链接是针对RequireJS的FAQ解释的 @H_404_1@
@H_404_1@If you manually code a script tag in HTML to load a script with an anonymous define() call,this error can occur.@H_404_1@ – 编辑 @H_404_1@如果你正在使用grunt,你可以使用grunt-generate轻松创建基于你自己的自定义模板的模块,当样板过载可能会破坏你的一天:) @H_404_1@免责声明:我写了Grunt插件.