我正在使用骨干样板(grunt-bbb)和requireJS进行项目,我有一个关于backbone.localstorage和lodash的问题。似乎localstorage插件需要下划线。我在我的应用程序config.js文件中为backbone.localstorage创建了一个别名:
paths: {
"backbone-localstorage" : "./plugins/backbone.localStorage"
},
将backbone.localstorage加载到我的一个模块后,我在underscore.js上遇到404错误。我假设这是因为bbb使用lodash。所以,我用require.config.js文件中的lodash.underscore.js文件替换了lodash,一切正常:
var jam = {
"packages": [
// more packages here...
{
"name": "underscore",
"location": "../vendor/jam/lodash",
"main": "./lodash.underscore.min.js"
}
],
"version": "0.2.11",
"shim": {
"backbone": {
"deps": [
"jquery",
"underscore"
],
"exports": "Backbone"
},
"backbone.layoutmanager": {
"deps": [
"jquery",
"backbone",
"underscore"
],
"exports": "Backbone.LayoutManager"
}
}
};
我的问题是,这是正确的方法吗?我应该在我的config.js文件中完成此操作,然后将下划线作为模块加载吗?