elementui点击table每一行会变色,当有固定列的时候,

1. html代码
@row-click="rowClick"css

:row-class-name="tableRowClassName"html

:row-style="selectedHighlight"this

2. js代码htm

// 解决当表格有固定列,点击,鼠标悬浮的时候行会变色的问题索引

tableRowClassName({ row, rowIndex }) {get

//把每一行的索引放进rowtable

row.index = rowIndex;class

},import

// 解决当表格有固定列,点击,鼠标悬浮的时候行会变色的问题cli

selectedHighlight({ row, rowIndex }) {

if (this.getIndex === rowIndex) {

return {

'background-color': '#ffeecf !important'

};

}

if(rowIndex % 2 == 0){

return {

'background-color': '#F9F9F9'

}

}

},

// 解决当表格有固定列,点击,鼠标悬浮的时候行会变色的问题

rowClick(row) {

this.getIndex = row.index;

},

3. css代码
/ 当table有fixed固定列的时候,鼠标悬浮同样会变色 /

.el-table__body .el-table__row.hover-row td {

background-color: #FFF9EE !important;

}