1.网上找的时间戳方法,我单独放在一个js里export function formatDate(timestamp) { var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000 Y = date.getFullYear() + '-'; M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-'; D = date.getDate() + ' '; h = date.getHours() + ':'; m = date.getMinutes() + ':'; s = date.getSeconds(); return Y+M+D+h+m+s;} 2.在XX.vue组件引入进来import {formatDate} from '@/assets/js/date.js'3.为了方便使用,用了过滤器filters:{ //时间戳 formatDate(time) { return formatDate(time); },}4.在列表中使用它(用了elementUI框架)<el-table-column prop="createTime" label="CREATETIME" sortable> <template slot-scope="scope"> {{ scope.row.createTime|formatDate }} </template></el-table-column> 5.执行结果这是怎么回事呀?
添加回答
举报
0/150
提交
取消