现在显示的格式如下图:
我期望统一格式,所以不妨前端处理一下,核心代码如下
filters: {
// 时间戳处理
formatDate: function(value, spe = '/') {
value = value * 1000
let data = new Date(value);
let year = data.getFullYear();
let month = data.getMonth() + 1;
let day = data.getDate();
let h = data.getHours();
let mm = data.getMinutes();
let s = data.getSeconds();
month = month >= 10 ? month : "0" + month;
day = day >= 10 ? day : "0" + day;
h = h >= 10 ? h : "0" + h;
mm = mm >= 10 ? mm : "0" + mm;
s = s >= 10 ? s : "0" + s;
return `${year}${spe}${month}${spe}${day} ${h}:${mm}:${s}`;
}
},
使用方法如下:
<text>{{item.create_time | formatDate('-')}}</text>
代码结构如下: