vue定义日期格式化过滤器

1.0 // 函数对象(Vue为一个函数,作为对象来使用)
//          Vue.filter('dateString',function(value,format){
//              return moment(value).format(format||'YYYY-MM-DD HH:mm:ss')
//          })
            
2.0 //也可以用形参默认值
            Vue.filter('dateString',function(value,format='YYYY-MM-DD HH:mm:ss'){
                return moment(value).format(format)
            })

 参看: http://momentjs.cn/

猜你喜欢

转载自www.cnblogs.com/shun1015/p/12663191.html