// 全局的时间过滤器
Vue.filter('dateFormat',function(originVal){
// 提到需要过滤的日期
const date = new Date(originVal)
// 获取年份
const Y = date.getFullYear()
// 获取月份 如果不足两位,在前面以0来补全
const M = (date.getMonth() + 1 + '').padStart(2,'0')
// 获取日 如果不足两位,在前面以0来补全
const D = (date.getDate() + '').padStart(2,'0')
// 小时
const hh = (date.getHours() + '').padStart(2,'0')
// 分钟
const mm = (date.getMinutes() + '').padStart(2,'0')
// 秒
const ss = (date.getSeconds() + '').padStart(2,'0')
// 返回出 年-月-日 时:分:秒
return `${Y}-${M}-${D} ${hh}:${mm}:${ss} `
})
//使用
<template slot-scope="scope">{{scope.row.add_time | dateFormat}}</template>