實現
在此列上添加template,顯示的內容調用函數parseDateFull,參數為后台返回的時間。
<el-table-column
label="處理時間"
align="center"
prop="clsj"
width="180"
>
<template slot-scope="scope">
<span>{{ parseDateFull(scope.row.clsj) }}</span>
</template>
</el-table-column>
然后定義函數parseDateFull的實現
parseDateFull(time:any) {
const x = new Date(time);
const z:any = {
y: x.getFullYear(),
M: x.getMonth() + 1,
d: x.getDate(),
h: x.getHours(),
m: x.getMinutes(),
s: x.getSeconds(),
};
if (z.M < 10) {
z.M = "0" + z.M;
}
if (z.d < 10) {
z.d = "0" + z.d;
}
if (z.h < 10) {
z.h = "0" + z.h;
}
if (z.m < 10) {
z.m = "0" + z.m;
}
return z.y + "-" + z.M + "-" + z.d;
},
