vue filters 过滤用法 时间戳方法

data:function(){
        return {
          time:1567739244120
        }
    },
    filters:{
        times:function(value){
            timestampToTime(value);
            function timestampToTime(timestamp) {
                var date = new Date(timestamp);
                Y = date.getFullYear() + '-';
                M = (date.getMonth()+1 < 10'0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
                D = date.getDate() + ' ';
                h = date.getHours() + ':';
                m = date.getMinutes() + ':';
                s = date.getSeconds();
                return Y+M+D+h+m+s;
            }
            return timestampToTime(value)
        }
    },

html

<div><span>{{item | times}}</span></div>
原文地址:https://www.cnblogs.com/chen527/p/11473875.html