少加冰~ 2022-01-05 17:37 采纳率: 66.7%
浏览 47
已结题

怎么改变表格的颜色[el-table]

下面的表格中怎么去根据条件改变指定行或者列的颜色呢?希望得到解答

img

  • 写回答

1条回答 默认 最新

  • 几何心凉 2022年度博客之星前端领域TOP 1 2022-01-05 17:47
    关注

    在表格中加入

    :cell-style="rowClass"
    
    

    rowClass方法如下

     rowClass(data) {
                    console.log(data);
                    if (data.column.label == "客服") {    //判断条件,在打印中找出要判断的条件    列
                        return "background: #D9EDF7;color:#34738f";
                    }
                    if (data.column.label == "本年应到") {
                        return "background: #D9EDF7;color:#34738f";
                    }   
                    if (data.row.doctor_text == "到院率") {
                        return "background: #D9EDF7;color:#34738f";
                    }//行row 
    
                }
            },
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 1月13日
  • 已采纳回答 1月5日
  • 创建了问题 1月5日