【发布时间】:2022-03-23 00:47:05
【问题描述】:
https://codesandbox.io/s/7mo0rvl971
检查这个例子。你们可以注意到我们可以点击名称,因为他们使用标签
如何单击名称并获取内容。例如,我单击单元格“John Brown”并返回字符串“John Brown”
【问题讨论】:
https://codesandbox.io/s/7mo0rvl971
检查这个例子。你们可以注意到我们可以点击名称,因为他们使用标签
如何单击名称并获取内容。例如,我单击单元格“John Brown”并返回字符串“John Brown”
【问题讨论】:
在最近的版本中,您可以只使用useRow 属性来设置onCLick 事件。你可以在这里看到这个:https://ant.design/components/table/#onRow-usage
【讨论】:
解决方法是在
上设置data-id<a data-id={text} onClick={this.onClick}>{text}</a>
然后
onClick = (e) => {
console.log('Content: ', e.currentTarget.dataset.id);
}
如果您想在特定列上添加点击事件,您可以在您的列对象中使用onCell。
const table_columns = [
{
title: 'Name',
dataIndex: 'name',
key: 'name',
onCell: (record, rowIndex) => {
return {
onClick: (ev) => {
console.log(record, rowIndex);
},
};
},
},
]
【讨论】:
这是简单明了的答案
const columns = [
{
title: 'Name',
dataIndex: 'name',
render:text=><Link to='/detail'>{text}</Link>
}]
const data = [
{
key: '1',
name: 'Organisation',
subType: 'Kindergarten',
ville: 'Brusseis',
email: 'info@example.com',
telephone: '+32477070505',
}]
【讨论】: