需求:点击table时,给当前点击行加背景色使其高亮显示
参考网址:https://blog.csdn.net/EasonGG/article/details/105687765
html部分代码:
<a-table
:columns="columns1"
:data-source="exitData"
:customRow="exitCustomRow"
size="middle"
>
</a-table>
js部分代码:
data() {
return {
customKey: ''
}
},
methods: {
exitCustomRow(record, index) {
return {
style: {
// 字体颜色
color: record.key === this.customKey ? 'red' : '',
// 背景颜色
'background-color': record.key === this.customKey ? 'rgb(0, 180, 237,0.1)' : ''
},
on: {
click: event => {
// 当前点击的行
this.customKey = record.key
}
}
}
}
}
最终效果: