<el-table-column prop="date" label="日期">
<template slot-scope="scope">{{pri_problem.in_date | timestampToTime}}</template>
</el-table-column>
利用 filters 转换时间
filters: {
timestampToTime: function(dates) {
var date = new Date(dates); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
var Y = date.getFullYear() + "-";
var M =
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-";
var D = date.getDate() + " ";
var h = date.getHours() + ":";
var m = date.getMinutes() + ":";
var s = date.getSeconds();
return Y + M + D + h + m + s;
console.log(timestampToTime(1533293827000));
}
},
网友评论