详解element-ui表格中勾选checkbox,高亮当前行

2020-06-14 06:13:57易采站长站整理

rowStyle({row, rowIndex}){
let arr = this.multipleSelection;
for(let i = 0; i < arr.length; i++){
if(rowIndex === arr[i]){
return 'rowStyle'
}
}
}

在style中定义选中行的样式


</style>
.rowStyle{
background-color:red!important;
}
</style>

另外如果想更改鼠标移入的hover样式,要注意需要在td上修改,因为事件是添加在td身上的,在tr上修改无效。


.el-table{
width: 1163px;
margin: 0 auto;
.el-table__body{
tr:hover>td{
background-color:rgba(238,250,249,1)!important;
}
}
}