过滤器 filters:{}

 //过滤前

              //过滤后


<div id="app" v-cloak>
   <p>{{timeDate | formatDate}}</p>
</div>

// 公用方法
var padDate=function(va){
     va=va<10?'0'+va:va;
     return va
};

filters:{
        formatDate:function (val) {
            var value=new Date(val);
            var year=value.getFullYear();
            var month=padDate(value.getMonth()+1);
            var day=padDate(value.getDate());
            var hour=padDate(value.getHours());
            var minutes=padDate(value.getMinutes());
            var seconds=padDate(value.getSeconds());
            return year+'-'+month+'-'+day+' '+hour+':'+minutes+':'+seconds;
        }

    }

猜你喜欢

转载自blog.csdn.net/yang295242361/article/details/79608124
今日推荐