私はrequire.jsを使用しています-requiredjsを使用すると、シムのエクスポートモジュールを使用せずにコンソールを使用している間、アンダースコアとバックボーンを取得できません。
しかし、jquery はこのエクスポート shim に依存することを求めていません。では、なぜ shim を使用する必要があり、それがアンダースコアとバックボーンのエクスポートなのですか?
ここに私のコードがあります:
requirejs.config({
baseUrl: 'js',
paths: {
"jquery":'lib/jquery-1.9.1.min',
"underscore":"lib/underscore-min",
"backbone" : "lib/backbone-min"
},
shim:{
"underscore":{
exports: '_'
//what is does here? without this i am getting undefined
},
"backbone":{
exports: 'Backbone'
//what is does here? without this i am getting undefined
}
}
});
require(["jquery","underscore","backbone"],function ($,_,Backbone) {
console.log($,_,Backbone);
//without shim export i am getting conosle like this:
// "function(), undefined, udefined" - why?
});