ant 组件点击行添加样式
html 代码
<a-table :data-source="data" bordered :customRow="clickRow" rowKey="id" :pagination="false" class="table">
<a-table-column key="id" title="分类名称" data-index="categoryNameCn" />
</a-table>
JS代码
clickRow (record, index) {
return {
on: {
// 鼠标单击行
click: event => {
console.log('record',record);
event.currentTarget.parentNode.querySelectorAll('tr').forEach(item => {
item.style.background = 'white'
item.style.color = 'black'
item.style.fontSize = '12px'
})
event.currentTarget.style.background = '#e6f7ff'
event.currentTarget.style.color = '#40a9ff'
event.currentTarget.style.fontSize = '14px'
}
}
}
},