我正在關(guān)注 Antd 的文檔,并嘗試使用此處antd 動(dòng)態(tài)表單項(xiàng)中的這段代碼:import { Form, Input, Button, Space } from 'antd';import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';const Demo = () => { const onFinish = values => { console.log('Received values of form:', values); }; return ( <Form name="dynamic_form_nest_item" onFinish={onFinish} autoComplete="off"> <Form.List name="users"> {(fields, { add, remove }) => ( <> {fields.map(field => ( <Space key={field.key} style={{ display: 'flex', marginBottom: 8 }} align="baseline"> <Form.Item {...field} name={[field.name, 'first']} fieldKey={[field.fieldKey, 'first']} rules={[{ required: true, message: 'Missing first name' }]} > <Input placeholder="First Name" /> </Form.Item> <Form.Item {...field} name={[field.name, 'last']} fieldKey={[field.fieldKey, 'last']} rules={[{ required: true, message: 'Missing last name' }]} > <Input placeholder="Last Name" /> </Form.Item> <MinusCircleOutlined onClick={() => remove(field.name)} /> </Space> ))} <Form.Item> <Button type="dashed" onClick={() => add()} block icon={<PlusOutlined />}> Add field </Button> </Form.Item> </> )} </Form.List> <Form.Item> <Button type="primary" htmlType="submit"> Submit </Button> </Form.Item> </Form> );};但是我遇到了這個(gè)錯(cuò)誤,當(dāng)我添加一些行,然后刪除其中一些行并最終提交時(shí),即使我刪除了這些行,驗(yàn)證器仍然繼續(xù)工作。https://i.stack.imgur.com/nNO8s.gif 這是一個(gè)復(fù)制我的錯(cuò)誤的演示。 https://codesandbox.io/s/quizzical-ride-m1pe6?file=/src/App.js
驗(yàn)證在 Antd 中以動(dòng)態(tài)形式繼續(xù)對(duì)已刪除的行進(jìn)行驗(yàn)證
慕田峪9158850
2023-07-29 14:53:35