pro-components icon indicating copy to clipboard operation
pro-components copied to clipboard

🐛[BUG] ProTable和ModalForm 同时用出现:Found 2 elements with non-unique id

Open imoxuan opened this issue 3 years ago • 0 comments
trafficstars

🐛 bug 描述

  1. 一个页面用户信息列表用的是 ProTable, 指定列内容时,让某一列例如 用户名 出现在 protable 的搜索区域。
  2. 点击新建按钮,弹窗 modalform,里面有用户名的表单项。

上面两个同时出现,就会报警告:Found 2 elements with non-unique id

也就是 ProTable 指定列时,列的dataIndex和modalform中的表单项name 相同时,且该列出现在protable的搜索区域时。

💻 复现代码

列表内容, 注意 ` const columns: ProColumns<UserApi.UserItem>[] = [ { title: "序号", dataIndex: "index", align: "center", valueType: "index", width: 80, }, { title: '账号', dataIndex: 'userName', } ] columns <ProTable<UserApi.UserItem> actionRef={actionRef} rowKey="id" columns={columns} request={userPageRecords} toolbar={{ settings: [] }} ... />

`

新增表单内容: ` <ModalForm<UserApi.UserItem> visible={visible} title={'新增'} ... > <ProForm.Group> <ProFormText width="md" name="userName" label="账号" placeholder="请输入账号" rules={[ { required: true, message: '请输入账号', }, ]} /> <ProFormText.Password width="md" name="password" label="密码" placeholder="请输入密码" rules={[ { required: true, message: '请输入密码', }, ]} /> </ProForm.Group> </ModalForm>

`

当把上面的 columns 改为下面的就不会出现,增加 hideInSearch: true ` const columns: ProColumns<UserApi.UserItem>[] = [ { title: "序号", dataIndex: "index", align: "center", valueType: "index", width: 80, }, { title: '账号', dataIndex: 'userName', hideInSearch: true } ]

`

© 版本信息

"@ant-design/pro-components": "1.1.1", "@ant-design/pro-layout": "6.38.13", "@ant-design/pro-table": "2.77.1", "@umijs/max": "4.0.7",

image

imoxuan avatar Jul 25 '22 03:07 imoxuan