覆盖瞬间js默认无效日期文本 [英] Override the moment js default invalid date text

查看:28
本文介绍了覆盖瞬间js默认无效日期文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何覆盖moment.js

How can I override the moment.js

var defaultInvalidDate = 'Invalid date';

无需更改 moment.js 文件.就像我的网站使用 Site.css 覆盖某些引导程序 css 样式一样,所以当引导程序更新时我不会丢失更改,有什么方法可以覆盖 momentjs 吗?

without changing the moment.js file. Just like my site overrides certain bootstrap css styles with a Site.css, so when bootstrap is updated I dont lose the changes, is there any way to make overrides for momentjs?

提前致谢

推荐答案

只需使用 moment.updateLocale(localeName, config) 更新 moment.js 使用的当前语言环境

Just update your current locale used by moment.js using moment.updateLocale(localeName, config)

moment.updateLocale(moment.locale(), { invalidDate: "Invalid Date Updated" })

这是工作示例:

console.log(moment(new Date("Aa")).format(""));
moment.updateLocale(moment.locale(), { invalidDate: "Invalid Date Updated" })
console.log(moment(new Date("Aa")).format(""));

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment.min.js"></script>

这篇关于覆盖瞬间js默认无效日期文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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