vue 前端时间格式处理 2022-06-12T00:00:00.000+0800
这里处理的 原始时间格式 为 :2022-06-12T00:00:00.000+0800需要达到的效果 :2022-06-12 00:00:00
·
这里处理的 原始时间格式 为 : 2022-06-12T00:00:00.000+0800
需要达到的效果 :2022-06-12 00:00:00
//安装
npm install moment
//main.js 文件
import moment from 'moment' //引入
// 挂载 时间处理 2022-06-12T00:00:00.000+0800
Vue.prototype.moment = moment
Vue.filter('dateFormat', function (dateStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
return moment(dateStr).format(pattern)
})
//应用 table
<el-table-column label="日期" width="150">
<template slot-scope="scope"> {{scope.row.dataTime | dateFormat}}</template>
</el-table-column>
更多推荐
已为社区贡献5条内容
所有评论(0)