elementui 表格table格式化时间戳

JS部分

<script>
import request from '@/api/request'

export default { 
  name: 'BlogManage',
  filters: { 
    /** * 格式化时间 * @param time * @returns {string} */
    formatDate(time) { 
      let date = new Date(time)
      let year = date.getFullYear()
      let month = date.getMonth()
      let day = date.getDate()
      let hour = date.getHours()
      let min = date.getMinutes()
      let second = date.getSeconds()
      return year + '-' + month + '-' + day + ' ' + hour + ':' + min + ':' + second
    }
  },
  //其他代码逻辑省略 。。。
}
</script>

    <el-table v-loading="listLoading" :data="blogList" element-loading-text="Loading" border fit highlight-current-row >
      <el-table-column align="center" label="ID" width="95">
        <template slot-scope="scope">
          {
  { scope.$index }}
        </template>
      </el-table-column>
      <el-table-column label="创建时间">
        <template slot-scope="scope">
          <!-- 这里 -->
          {
  { scope.row.createDate | formatDate}}
        </template>
      </el-table-column>

    </el-table>

    原文作者:人在码中跑_发在天上飞
    原文地址: https://blog.csdn.net/qq_40738239/article/details/123876541
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞