第2世界
发布于 2023-06-14 / 14 阅读 / 0 评论 / 0 点赞

antd table row 取消hover样式

在自定义了row的click事件后可以自己对行的样式进行处理,这会与默认的hover样式冲突,解决办法

CSS覆盖:

tr.no-hover:hover:not(.selected),tr.no-hover>td.ant-table-cell-row-hover:not(.selected){
  background-color:transparent !important;
}

JSX:

<Table onRow={(record,index)=>({onClick:(event)=>setSelected(index)})} rowClassName={(record,index)=>index===selected?'bg-green-500 no-hover selected':"no-hover"} />


评论