template
<el-table
:data="data"
:row-class-name="tableRowClassName" //设置类
:row-style="selectedstyle" //设置行的样式
@row-click="rowClick" //点击
>
</el-table>
script
data() {
return {
data:[],
getIndex:"",
}
},
methods: {
selectedstyle ({row, rowIndex}) {
if ((this.getIndex) === rowIndex ) {
return {
"background-color": "red"
};
}
},
tableRowClassName ({row, rowIndex}) {
row.index = rowIndex;
},
rowClick (row) {
this.getIndex=row.index
}
}