实现
在此列上添加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;
},