1、封装
import * as dayjs from 'dayjs'
const utc = require('dayjs/plugin/utc')
dayjs.extend(utc)
export const transformDate = (date, type = 'YYYY-MM-DD') => {
return dayjs.utc(date).format(type)
}
2、引入
import { transformDate } from '@/utils/transform-date'
3、方法
// 时间转化格式
transformDay (time, format) {
return transformDate(time, format)
},
4、使用
<div slot="updated_at" slot-scope="text">
<p>{{transformDay(text,type = 'YYYY.MM.DD')}}</p>
</div>