vue フロントエンドの時刻形式処理 2022-06-12T00:00:00.000+0800

ここで処理される元の時刻形式は次のとおりです: 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>

おすすめ

転載: blog.csdn.net/Yoga99/article/details/125260186