我使用的是require.js,一切都正确。我在文档中看到了js加载。在安慰的情况下,我得到的所有参数除了Backbone。为什么Backbone没有登录到控制台?
这是我的代码:
requirejs.config({
baseUrl : "scripts",
paths : {
"jquery" :"lib/jquery-min",
"loDash" :"lib/lodash-min",
"backBone" :"lib/backbone-min"
//this is exist load in document header, not console
}
});
require(["jquery","loDash","backBone"], function($,_,bB){
console.log($,_,bB);//jquery, underscore console correctly.
// 3rd one "bB" - stand for backbone, it console as undefined - why?
});
我在文档中加载了所有js,包括Backbone。
答案 0 :(得分:1)
我添加了垫片,它工作正常。
requirejs.config({
baseUrl : "scripts",
paths : {
"jquery" :"lib/jquery-min",
"loDash" :"lib/lodash-min",
"backBone" :"lib/backbone-min"
},
shim : {
"backBone":{
deps :["loDash"],
exports :"Backbone"
}
}
});
require(["jquery","loDash","backBone"], function ($,_,bB) {
console.log($,_,bB);
});