Backbone.js的和Require.js:不匹配的匿名定义()模块:功能(_,骨干){ [英] Backbone.js and Require.js: Mismatched anonymous define() module: function (_, Backbone) {
本文介绍了Backbone.js的和Require.js:不匹配的匿名定义()模块:功能(_,骨干){的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是新来使用require.js,并具有以下app.js文件作为我的骨干应用程序的一部分:
I am new to using require.js and have the following app.js file as part of my backbone app:
require.config({
baseUrl: "/js/",
paths: {
jquery: 'libs/jquery-2.1.0',
underscore: 'libs/underscore-min',
backbone: 'libs/backbone-min'
},
shim: {
underscore: {
exports: "_"
},
backbone: {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
}
});
在我的index.html文件的标记,我把以下内容:
In a tag in my index.html file, I have placed the following:
define(['underscore', 'backbone'], function (_, Backbone) {
不过,我收到以下错误我的index.html文件:
However, I am getting the following error my index.html file:
Uncaught ReferenceError: Backbone is not defined
在我require.js文件以下内容:
And the following in my require.js file:
Uncaught Error: Mismatched anonymous define() module: function (_, Backbone) {
任何线索?
推荐答案
我在上面使用的配置,
正如你可以看到你我比较样本图像的方法来声明,有minimals进行比较:
As you can see comparing my sample image with you way to declare, is there minimals diffs:
- 您不需要在
路径
声明垫片
库,只需使用相同的名称 - 我的baseUrl开始对我的
JS \\ lib中
文件夹中; - 我在我的JSON使用的配置文件名;
- You don't need to declare
shim
libs atpaths
, just use the same name; - My baseUrl starts on my
js\lib
folder; - I'm using file name on my json config;
当我宣布设置我的主HTML页面上我使用这样的:
When I declare the "setup" on my main html page I'm using like that:
<script data-main="js/setup.js" src="js/lib/require.js"></script>
这篇关于Backbone.js的和Require.js:不匹配的匿名定义()模块:功能(_,骨干){的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文