created() {
this.getData();
},
mounted() {},
filters: {
conversion: function (value) {
// console.log(value);
// console.log(moment("2021-10-5").unix());
// console.log(moment(parseInt(1633363200)).format("YYYY-MM-DD"));
function add0(m) {
return m < 10 ? "0" + m : m;
}
function format(value) {
//shijianchuo是整数,否则要parseInt转换
var time = new Date(parseInt(value));
var y = time.getFullYear();
var m = time.getMonth() + 1;
var d = time.getDate();
var h = time.getHours();
var mm = time.getMinutes();
var s = time.getSeconds();
return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s)
}
return format(value)
},
},
输出的格式是:1970-01-19 21:10:04
<div>
<Table border :columns="columns5" :data="tableData">
<template slot-scope="{ row }" slot="time">
<strong>{{ row.time | conversion }}</strong>
</template>
<template slot-scope="{ row }" slot="Custodian">
<strong>{{ row.Custodian == 1 ? "是" : "否" }}</strong>
</template>
<template slot-scope="{ row }" slot="penghua">
<strong>{{ row.penghua == 1 ? "是" : "否" }}</strong>
</template>
</Table>
</div>