<el-table
:data="parentTable"
@row-click="row_click_parent"
row-key="id"
:row-class-name="getRowClassName"
style="width: 100%"
>
先绑定方法 row-key row-class-name
const currentRowId = ref(null);
const row_click_parent = (row: any) => {
currentRowId.value = row.id;
};
const getRowClassName = ({ row, rowIndex }) => {
if (currentRowId.value == row.id) {
return "highlight-row";
}
return "";
};
判断点击行id和绑定id是否相等 添加class
:deep(.highlight-row) {
background-color: #faecd8 !important;
}
最后写css样式