vue2.0的Element UI的表格table列时间戳格式化
表格属性
[html] view plain copy
- <el-table
- :data=”tableData”
- v-loading.body=”loading”
- border
- @selection-change=”selectionChange”
- style=”width: 100%”>
- <el-table-column
- prop=”createTime”
- label=”创建时间”
- :formatter=”dateFormat”
- width=”150”>
- <el-table-column
- prop=”updateTime”
- label=”更新时间”
- width=”150”>
script
[javascript] view plain copy
- new Vue({
- el: ‘#tableView’,
- data: {
- //列表数据
- tableData: [{
- “createTime”:1491559642000,
- “updateTime”:1491559642000
- }],
- },
- methods:{
- //时间格式化
- dateFormat:function(row, column) {
- var date = row[column.property];
- if (date == undefined) {
- return “”;
- }
- return moment(date).format(“YYYY-MM-DD HH
ss”);
- }
- }
- });
简单来说,vue组件传入的方法函数应该使用v-bind属性绑定
时间格式化使用moent.js
还没有评论,来说两句吧...