gpt4 book ai didi

javascript - RequireJS 未捕获错误 : Mismatched anonymous define() module

转载 作者:搜寻专家 更新时间:2023-11-01 04:17:54 25 4
gpt4 key购买 nike

在一个最小的应用程序中使用 RequireJS 和 Backbone,我总是得到

Uncaught Error: Mismatched anonymous define() module

即使该应用程序继续运行。这里是: https://assets.site44.com/admin/

我在 index.html 中包括了 jQuery、下划线、 Backbone ,因为我想缩短每个 View /模型中的 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 的常见问题解答,解释了这一点

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 插件。

关于javascript - RequireJS 未捕获错误 : Mismatched anonymous define() module,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20239341/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com