element-ui的el-table改变单个单元格的背景颜色(根据不同类型)
element-ui的el-table改变单个单元格的背景颜色效果图如下:需要在el-table 标签中添加 :cell-style=" " 方法代码如下(页面结构)代码如下(方法处理)methods: {// 背景颜色处理tableCellStyle ({row, column, rowIndex, columnIndex}) {if(columnIndex === 11) {// 表格的
·
element-ui的el-table改变单个单元格的背景颜色
效果图如下:
-
需要在el-table 标签中添加 :cell-style=" " 方法
-
代码如下(页面结构)
-
代码如下(方法处理)
methods: {
// 背景颜色处理
tableCellStyle ({row, column, rowIndex, columnIndex}) {
if(columnIndex === 11) { // 表格的第11行做处理
if(fxdj == 4) { // 如果是低风险背景色蓝色,字体色白色
return 'background:blue; color:white'
}else if(fxdj == 2) { // 较大风险
return 'background:orange'
}else if(fxdj == 1) { // 重大风险
return 'background:red'
} else { // 一般风险
return 'background:yellow'
}
}else {
return ''
}
},
}
更多推荐
已为社区贡献1条内容
所有评论(0)