【发布时间】:2021-02-22 14:06:45
【问题描述】:
【问题讨论】:
【问题讨论】:
Antd 会扫描Tabs 的直接子节点来构建导航。实现这一点的更好方法是使用条件 JSX:
{isAdmin && (
<TabPane tab="Tab 3" key="3">
Content of Tab Pane 3
</TabPane>
)}
如果你想将数据注入到你的表格中,你可以通过另一个组件传递道具,但不能隐藏导航链接,因为 Antd 会检测到它并将其添加到导航中:
<Role isAdmin tab="Tab 3" key="3">
Content of Tab Pane 3
</Role>
// ...
function Role({ isAdmin, children, ...rest }) {
// Work with isAdmin;
return <TabPane {...rest}>{children}</TabPane>;
}
【讨论】: