2016-12-15 423 views
0

我使用bootstrap3 datetimepicker,並且想要將日曆日期/時間格式更改爲瀏覽器的區域設置。使用RequireJS時,moment.locale(String)不起作用

我正在使用requirejs異步加載模塊。

var global_component = 'my custom path...'; 

var require = { 
    paths: { 
    // Components. 
    'jquery': global_component + '/jquery/dist/jquery.min', 
    'moment': global_component + '/moment/min/moment-with-locales.min' 
    } 
}; 

define(['jquery', 'moment', function ($, moment) { 

    var mylocale = window.navigator.userLanguage || window.navigator.languages[0]; 
    moment.locale(mylocale); 

    console.log(moment.locale()); 
}); 

我希望將moment類的全局語言環境更改爲「zh」,但它仍然是「en」。任何想法?

謝謝。

回答

相關問題