elemnet.ui表格中的全选/单选后当前表格背景色改变

今天跟大家分享一下elemnet.ui表格中的全选/单选后当前表格背景色改变`

首先是单选:

`

然后直接在公共的css样式中加入

.el-table--enable-row-hover .el-table__body tr:hover>td{
background-color: #212e3e !important;
}

接下来是多选


`

在data中定义一个numbers:[],
// 全选变色
handselectall(val){
	this.handleSelectionChange(val);
},
 handleSelectionChange(row) {
    console.log(row);
	row.forEach((value,index)=>{
		this.numbers.push(value.id);
	})
    },
// 选中背景色
tableRowClassName({ row, rowIndex }) {
  let color = "";
  this.numbers.forEach((r, i) => {
    if (rowIndex === r) {
      color = "warning-row";
    }
  });
  return color;
}
```然后在样式中加入
.warning-row{
background-color: #212e3e !important;
}

完事,有什么可以给我留言,因为我们公司的代码都是复制不出去的,所以又写了一遍。祝各位小伙伴天天好心情哦

你可能感兴趣的:(个人,vue,html)