--- order: 4.2 title: zh-CN: 复杂的动态增减表单项 en-US: Complex Dynamic Form Item --- ## zh-CN 这个例子演示了一个表单中包含多个表单控件的情况。 ## en-US This example demonstrates the case that a form contains multiple form controls. ```jsx import { Form, Input, Button, Space, Select } from 'antd'; import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; const { Option } = Select; const areas = [ { label: 'Beijing', value: 'Beijing' }, { label: 'Shanghai', value: 'Shanghai' }, ]; const sights = { Beijing: ['Tiananmen', 'Great Wall'], Shanghai: ['Oriental Pearl', 'The Bund'], }; const Demo = () => { const [form] = Form.useForm(); const onFinish = values => { console.log('Received values of form:', values); }; const handleChange = () => { form.setFieldsValue({ sights: [] }); }; return (
{(sights[form.getFieldValue('area')] || []).map(item => ( ))} )} remove(field.name)} /> ))} )} ); }; export default () => ; ```