--- order: 1 title: zh-CN: 表单方法调用 en-US: Form methods --- ## zh-CN 通过 `Form.useForm` 对表单数据域进行交互。 ## en-US Call form method with `Form.useForm`. ```tsx import { Form, Input, Button, Select } from 'antd'; const { Option } = Select; const layout = { labelCol: { span: 8 }, wrapperCol: { span: 16 }, }; const tailLayout = { wrapperCol: { offset: 8, span: 16 }, }; const Demo = () => { const [form] = Form.useForm(); const onGenderChange = value => { form.setFieldsValue({ note: `Hi, ${value === 'male' ? 'man' : 'lady'}!`, }); }; const onFinish = values => { console.log(values); }; const onReset = () => { form.resetFields(); }; const onFill = () => { form.setFieldsValue({ note: 'Hello world!', gender: 'male', }); }; return (
prevValues.gender !== currentValues.gender} > {({ getFieldValue }) => { return getFieldValue('gender') === 'other' ? ( ) : null; }}
); }; ReactDOM.render(, mountNode); ``` ```css #components-form-demo-control-hooks .ant-btn { margin-right: 8px; } ```