# table格式化数据formatter
onInit() {
this.columns.forEach(column => {
//修改颜色
if (column.field == '字段') {
//格式化返回自定义单元格内容
column.formatter = (row) => {
return '<span style="color: #2d8cf0;">' + row.字段 + '</span>'
}
//单元格绑定事件
column.click = (row, column, event) => {
this.$message.info(row.字段);
};
}
//格式化日期
if (column.field == 'CreateDate') {
column.formatter = (row) => {
return (row.CreateDate || '').split(' ')[0].replace(/-/g, '.')
}
}
})
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22