iview table column 中使用 moment组件将 后端传入的时间戳格式化为 yyyy-MM-dd HH:mm:ss
1.引入moment.js
npm install moment.js
2.main.js中全局引入:
/*引入moment*/ import moment from 'moment' Vue.prototype.$moment = moment;
然后就可以 用
this.$moment() 对日期时间进行格式化了
3.iview table column 中使用:
{ title: '时间', key: 'createTime', align: 'center', // width: 160, render: (h, params) => { return h('div', this.$moment(params.row.createTime).format('YYYY-MM-DD HH:mm:ss') ) } }
更多 moment.js 用法参考 http://momentjs.cn/