我正在尝试以基于https://github.com/jquery/globalize/blob/master/doc/的高级方式运行的 gloablize ( https://github.com/jquery/globalize ) 的纯 JS 示例cldr.md _
因此,我创建了一个加载器脚本来加载所有依赖项:
var url = new URL(window.location.href);
//STATIC_URL: global variable from base.html
$.when(
$.getScript( url.origin + STATIC_URL + "js/globalize2/cldrjs/cldr.js" ),
$.getScript( url.origin + STATIC_URL + "js/globalize2/cldrjs/cldr/event.js" ),
$.getScript( url.origin + STATIC_URL + "js/globalize2/cldrjs/cldr/supplemental.js" ),
$.getScript( url.origin + STATIC_URL + "js/globalize2/globalize.js" ),
$.getScript( url.origin + STATIC_URL + "js/globalize2/globalize/date.js" ),
$.getScript( url.origin + STATIC_URL + "js/globalize2/globalize/number.js" ),
$.getScript( url.origin + STATIC_URL + "js/globalize2/globalize/plural.js" ),
$.Deferred(function( deferred ){
$( deferred.resolve );
})
).done(function(){
$.when(
$.get( url.origin + STATIC_URL + "js/globalize2/cldr/main/de/ca-gregorian.json" ),
$.get( url.origin + STATIC_URL + "js/globalize2/cldr/supplemental/likelySubtags.json" ),
$.get( url.origin + STATIC_URL + "js/globalize2/cldr/supplemental/timeData.json" ),
$.get( url.origin + STATIC_URL + "js/globalize2/cldr/supplemental/weekData.json" )
).then(function() {
// Normalize $.get results, we only need the JSON, not the request statuses.
return [].slice.apply( arguments, [ 0 ] ).map(function( result ) {
return result[ 0 ];
});
}).then( Globalize.load ).then(function() {
// Your code goes here.
});
});
据我在 Firebug 中看到的,所有文件都已正确加载。但是当涉及到Globalize.load
步骤时,引用被标记为未定义。
我现在不知道出了什么问题。欢迎任何帮助。