vue 使用moment

1.下载 cnpm i moment --save
2.main.js 挂载
import moment from ‘moment’//导入文件
Vue.prototype.$moment = moment;//赋值使用
3.组件中使用

凡是用的prototype   使用都要this.继承

this.$moment(‘string’).format(“YYYY-DD-MM”)

this.$moment(‘2018-09-19T05:54:32.767Z’).format(“YYYY-DD-MM”)

浏览器解析后 2018-09-19

作者:丰起云啸
链接:https://www.jianshu.com/p/c26d6215b6c6
来源:简书

发布了9 篇原创文章 · 获赞 0 · 访问量 641

猜你喜欢

转载自blog.csdn.net/qq_45284875/article/details/103341656
今日推荐