pro-components
pro-components copied to clipboard
🧐[问题]ProFormList里的ProFormTable
提问前先看看:
https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md
🧐 问题描述
用ProFormList 循环组 <SelectModal />,组件里有个Modal,Modal又有 ProFormTable ,ProFormTable request={async (params) params 打印的结构是 {0:{state: 1},current: 1,pageSize: 20} , {1:{state: 1},current: 1,pageSize: 20},为什么这样,对象key值是数字?
💻 示例代码
---------------------------------ProFormList
<ProForm onFinish={async (e) => console.log(e)}> <ProFormList name="labels" label="用户信息" initialValue={[ { value: "333", label: "333", }, { value: "222", label: "222", }, { value: "111", label: "111", }, ]} creatorButtonProps={false} copyIconProps={false} deleteIconProps={false} > <ProFormGroup key="group"> <SelectModal /> </ProFormGroup> </ProFormList> </ProForm>
---------------------------------SelectModal
🚑 其他信息
---------------------------------SelectModal
<ProTable<GithubIssueItem>
columns={columns}
request={async (params) => {
console.log(params)
return {
data: [
{
key: 1,
name: TradeCode ${1},
createdAt: 1602572994055,
state: "closed",
},
],
success: true,
}
}}
rowKey="key"
dateFormatter="string"
search={{
defaultCollapsed: false,
optionRender: (searchConfig, formProps, dom) => [
...dom.reverse(),
<Button
key="out"
onClick={() => {
const values = searchConfig?.form?.getFieldsValue()
console.log(values)
}}
>
导出
</Button>,
],
}}
/>
升级下版本试试,这个是因为 portable 本质上是个列表,所以用了 0 1 来当key。保证每一行都有一个唯一的key。但是有个版本的判断有问题,数组和对象没分清楚导致了问题