我目前正在尝试使用带有require.js的moment.js库,但我仍然无法理解这样一个项目的正确设置.这是我在main.js文件中的操作:
requirejs.config({
baseUrl: 'app',
paths: {
// ... more parameters (all Backbone related)
'moment': 'lib/moment',
'moment_de': 'lib/lang/de',
},
shim: {
'moment' : {
deps: [],
},
'moment_de': {
deps: ['moment'],
},
// ... more parameters (all Backbone related)
}
});
Run Code Online (Sandbox Code Playgroud)
我正在使用单独的模块进行配置.该模块如下所示:
define(['moment', 'moment_de'], function(moment, de) {
moment.lang('de');
var configuration = {}
// ...
return configuration;
});
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我正在尝试更改此文件中的moment对象的全局语言,但我遇到以下错误消息:
Uncaught Error: Module name "../moment" has not been loaded yet for context: _. Use require([])
Run Code Online (Sandbox Code Playgroud)
后来:
Uncaught TypeError: Cannot call method 'preparse' of …Run Code Online (Sandbox Code Playgroud)