【发布时间】:2021-01-05 14:36:18
【问题描述】:
我在 Next.js v10.0.4 的应用中使用了 antd design 4.10 版的可扩展表格。当我点击表格中的+ 按钮时,它假设只打开选定的行,但我不知道为什么它同时打开所有行。
这是我的表格组件:
<Table
size="small"
dataSource={data}
columns={updateColumns}
expandable={{
expandedRowRender: (record) => (
<p style={{ margin: 0 }}>{record.description}</p>
),
rowExpandable: (record) => record.level !== "3",
onExpand: (expanded, record) =>
console.log("onExpand: ", record, expanded),
}}
/>
与antd设计中的文档代码完全相同:https://ant.design/components/table/#components-table-demo-expand
【问题讨论】:
-
听起来您的数据中的每条记录都缺少
key字段。 -
@Scratch'N'Purr 没错,钥匙不见了,我将 rowkey={(record) => record.stationId} 添加到我的表格组件中,现在可以正常工作了,谢谢。跨度>
标签: next.js antd expandable-table