背景:使用 script 标签,在 html 页面中引入了 moment.js,使用时发现页面中 moment.js 相关的文字显示的是英文(eg:3 days ago),但我希望这里能够显示中文
解决过程:
Step1:百度后,在 html 中添加:moment.locale('zh-cn');
Resulte1:moment.locale() 不生效
Step2:在 moment.js 中查找:defaultRelativeTime,对其进行修改
Resulte2:成功
PS:moment.js 的各种语言包在 github 上有,地址:https://github.com/moment/moment/tree/develop/locale