在最小的应用程序中使用RequireJS和Backbone,我总是得到
Uncaught Error: Mismatched anonymous define() module
即使该应用程序继续工作.这里是:
https://assets.site44.com/admin/
我在index.html中包含jQuery,下划线,主干,因为我想缩短每个视图/模型中的define()样板.
https://assets.site44.com/admin/js/main.js由
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)
我无法从文档或这个回答的问题中找出问题:
Mismatched anonymous define() module
谢谢
I’m including jQuery,underscore,backbone in index.html,since I want to shorten the define() boilerplate in each view/model.
你不应该.如果您google “Uncaught Error: Mismatched anonymous define() module”,您会注意到最上面的链接是针对RequireJS的FAQ解释的
If you manually code a script tag in HTML to load a script with an anonymous define() call,this error can occur.
– 编辑
如果你正在使用grunt,你可以使用grunt-generate轻松创建基于你自己的自定义模板的模块,当样板过载可能会破坏你的一天:)
免责声明:我写了Grunt插件.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。