vue自定义时间过滤器

**// 自定义事件过滤器**
Vue.filter('dateFormat', function (originVal) {
  var dt = new Date(originVal)
  var y = dt.getFullYear()
  var m = (dt.getMonth() + 1 + '')
  var d = (dt.getDate() + '')
  var hh = (dt.getHours() + '')
  var mm = (dt.getMinutes() + '')
  var ss = (dt.getSeconds() + '').padStart(2, '0')

  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})
使用: <template slot-scope="scope">{{scope.row.add_time|dateFormat}}</template>
将时间戳转为日期格式

猜你喜欢

转载自blog.csdn.net/qq_41792374/article/details/106887484