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