MomentJS不加载语言环境 [英] MomentJS doesn't load locales

查看:356
本文介绍了MomentJS不加载语言环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用moment和nodejs构建一些东西,但是由于某些原因,语言环境没有被加载.这是一些代码:

I am building something with moment and nodejs, but for some reason, the locales don't get loaded. Here is some code:

import moment from 'moment'

moment.locale('fr');
console.log(moment.locales());

因此console.log仅返回en语言环境,因此我认为未加载其他语言环境.

So the console.log only returns the en locale so I suppose that the other locales aren't loaded.

但是,文档说:

如果moment-root/locale/中有一个以该键命名的语言环境文件, 第一次调用moment.locale会加载它.

If there is a locale file in moment-root/locale/ named after that key, the first call to moment.locale will load it.

当我签入node_modules/moment/locale时,确实确实有一个fr.js文件.

When I check in my node_modules/moment/locale, I have indeed a fr.js file.

那么我在做什么错了?我是否缺少某些东西来加载我的语言环境?

So what am I doing wrong? Am I missing something to load my locales?

非常感谢您的帮助!

我正在使用momentjs的版本^2.14.1

I am using version ^2.14.1 of momentjs

推荐答案

根据文档,请确保您已导入语言环境文件或使用了缩小文件:

According to documentation please make sure that you have imported locale files or used minified file:

locale/*.js

min/moment-with-locales.js

这篇关于MomentJS不加载语言环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆