antdv之使用customRow属性实现table当前点击行高亮

这篇博客介绍了如何通过JavaScript和CSS实现点击HTML表格行时,给当前被点击行添加背景色以达到高亮显示的效果。示例代码包括在A-Table组件中设置customRow属性,监听点击事件,并动态改变行的样式。通过这种方法,可以提升用户交互体验。
摘要由CSDN通过智能技术生成

需求:点击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
          }
        }
      }
    }
}

最终效果:
在这里插入图片描述

  • 5
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值