<el-table
:data="data"
:row-class-name="tableRowClassName" //给这一行加类
:row-style="selectedHighlight" //设置这一行的样式
@row-click="rowClick" //单击时调用的函数
>
</el-table>
<script>
selectedHighlight({row, rowIndex}) {
if ((this.getIndex) === rowIndex ) {
return {
"background-color": "rgb(250, 195, 100)"
};}},
tableRowClassName ({row, rowIndex}) {
//把每一行的索引放进row
row.index = rowIndex;
},
rowClick (row) {
console.log(row,"row");
this.getIndex=row.index
},
</script>