7
我使用require.version“2.0.0”
我想获得下划线作为一个局部变量:Requirejs,在加载库问题突出
这里是我的代码(1)。
为什么_未定义?
我怎样才能得到_
里面的功能就像一个局部变量
(1)
require.config({
baseUrl: "./",
paths: {
'underscore': 'vendor/js/underscore-min'
},
shim: {
'underscore': {
exports: 'underscore'
}
}
});
require([
'underscore'
], function(_) {
"use strict";
console.log(_); // undefined
});
您是否使用Underscore的https分支https://github.com/amdjs/underscore?如果没有,这可以解释您的问题 – nikoshr
@nikoshr感谢您的评论。我没有使用Underscore的AMD分支。无论如何有没有办法解决这个问题,而不使用AMD版本? –
@nikoshr无论如何,如果你看这[文章](http://tbranyen.com/post/amdrequirejs-shim-plugin-for-loading-incompatible-javascript)似乎垫片已被引入修复非AMD插件。 –