antd中如何给table行添加data-testid?
How to add a data-testid to a table row in antd?
我想将自定义 data-testid
添加到 antd table 中的 行 ,但是从 docs 我不知道看不到如何连接注释 table 行 本身。知道如何做到这一点吗?
作为替代方案,您可以使用 table 的 rowClassName
属性 向特定行添加 class:
const classNameGenerator = (record, index) => {
if(record.id == 2) {
return "my-special-row";
}
return "";
};
<Table columns={columns} dataSource={data} rowClassName={classNameGenerator} />
我想将自定义 data-testid
添加到 antd table 中的 行 ,但是从 docs 我不知道看不到如何连接注释 table 行 本身。知道如何做到这一点吗?
作为替代方案,您可以使用 table 的 rowClassName
属性 向特定行添加 class:
const classNameGenerator = (record, index) => {
if(record.id == 2) {
return "my-special-row";
}
return "";
};
<Table columns={columns} dataSource={data} rowClassName={classNameGenerator} />