Vue的时间过滤器(毫秒转化为年月日时分秒的形式)
在main.js中全局注册过滤器
// 全局注册自定义的日期过滤器dataFormat,传参值originVal为毫秒
Vue.filter(‘dateFormat’,function(originVal){
// 先把传参毫秒转化为new Date()
const dt = new Date(originVal)
const y = dt.getFullYear()
// 月份是从0开始,需要+1。 +’‘是把数字转化为字符串,padStart(2,‘0’)是把字符串设置为2位数,不足2位则在开头加’0
原创
2020-07-16 08:36:30 ·
2594 阅读 ·
0 评论