Jquery 当前未加载区域设置插件
我正在使用Jquery 当前未加载区域设置插件,jquery,momentjs,Jquery,Momentjs,我正在使用时刻、时刻区域设置和时刻时区插件来支持插件的区域设置和时区 我正在使用requireJs,下面是我的配置文件的内容: require.config({ baseUrl: '.', paths: { 'jQuery': '../path to jQuery plugin', 'moment': '../path to moment js plugin', 'momentLocale':'../path to moment l
时刻
、时刻区域设置
和时刻时区
插件来支持插件的区域设置和时区
我正在使用requireJs
,下面是我的配置文件的内容:
require.config({
baseUrl: '.',
paths: {
'jQuery': '../path to jQuery plugin',
'moment': '../path to moment js plugin',
'momentLocale':'../path to moment locale js plugin',
'momentTimeZone':'../path to moment timezone js plugin'
},
shim: {
'moment': {
deps: ['jQuery']
},
'momentLocale': {
deps: ['moment']
}
}
});
我遵循了,也在shim中包含了区域设置,并使用moment
编辑时区库,以momentLocale
支持日历区域设置和时区
我将区域设置值传递给返回默认区域设置的方法。
在我的应用程序中,我有很多目前js不支持的语言。为了克服这个问题,我正在维护映射表以返回即时支持的语言。(例如:如果我选择af_NA作为区域,它应该返回“af”作为语言
define([
'jQuery',
'moment',
'momentLocale'],
function(
$,
moment,
momentLocale ) {
getLocaleForCal: function(region) {
switch(region): {
case "af_NA":
case "af_ZA":
return "af";
break;
default:
return "en";
break;
}
}
};
});
下面是我要传递给calendar的选项
$(function() {
var currentRegion = this.getLocaleForCal("af_NA");
$("#datetimepicker2").datetimepicker({
locale: moment.locale(currentRegion)
});
});
默认情况下,区域设置显示为“en”,而不是“af”。因为此时区域设置没有加载,所以它将值设置为“en”
我做错了什么?我该如何修复它
提前谢谢。我也遇到了同样的问题。我刚刚添加了moment-timezone-with-data-2010-2020.js的新引用,对我来说效果很好。因此我的建议是在moment.js文件之前添加此文件的引用/要求。
momentTimeZone
还应添加到shim
部分可能重复的可能dup非常感谢hanmina,在我使用了MomentLocale插件之后,“uncaughttypeerror”这一点已经得到了修复,该插件没有加载。