el-table 中定义 formatter 方法名
<el-table-column
prop="warnReasons"
label="类型"
:formatter="formatterReason"
></el-table-column>
methods 中定义方法
formatterReason(row, column, cellValue) {
const h = this.$createElement
switch (cellValue) {
case '正常':
return h('p', { style: 'color: green' }, '正常')
break;
case '报警':
return h('p', { style: 'color: red' }, '报警')
break;
}
},