vue3 时间格式转换方法
后端返回的时间转换成想要展示的格式
如后端返回的时间格式
2022-08-21T12:00:48.595+08:00
这需要转换成我们响应的格式
2022-08-21 12:00:48
实现如下:
引用dayjs
npm install dayjs
//js引入
import dayjs from "dayjs"
//methods
//format 定义需要显示的格式
dataFliter(val,format = "YYYY-MM-DD hh:mm:ss"){
console.log(val)
// val = parseInt(val);
console.log(val)
return dayjs(val).format(format);
}
在vue中使用
<template v-slot="scope">
<el-tag >{{dataFliter(scope.row.CreatedAt)}}</el-tag>
</template>