を使用/ロードしようとしてUnderscoreJS
1.7.0
いますRequireJS
2.1.14-3
。私のアプリケーションの起動時、UnderscoreJS は適切にロードされていますが、「未定義」です。以下の詳細を参照してください。
main.js
define(function() {
// Configuration of RequireJS
requirejs.config({
enforceDefine : true,
map : {
'*': {
...
'underscore' : 'webjars/underscorejs/1.7.0/underscore'
},
},
// The base URL is just the top-level directory where the files are stored
baseUrl : './',
// Kick-start the application by loading these files
deps : [ 'MyPanel' ],
});
});
それを使用するモジュール:
define(['ractive',
'underscore',
...],
function(Ractive,
_,
...){
var Foo = Ractive.extend({
...
oninit: function(){
var anArray = [1, 2, 3]
_.each(anArray, function(item){
...
})
}
}
そしてブラウザコンソールの結果:
underscoreJS ファイルはブラウザーによって読み込まれます。
これは詳細である必要がありますが、Javascript
依存関係をmaven
と で管理しましたwebjars
では、なぜ私の_
undefined
ですか?