1、下载 dayjs 并导入到当前组件中
npm install dayjs --save
import dayjs from 'dayjs'
2、创建格式化入职日期的过滤器
filters: {
// 格式化入职日期的方法
formatTime(time) {
return dayjs(time).format('YYYY-MM-DD')
}
}
3、改造页面结构
<el-table-column sortable label="入职时间">
<template slot-scope="scope">
<span>{{ scope.row.timeOfEntry | formatTime }}</span>
</template>
</el-table-column>