--- order: 1 title: zh-CN: 表单方法调用 en-US: Form methods --- ## zh-CN 通过 `Form.useForm` 对表单数据域进行交互。 > 注意 `useForm` 是 [React Hooks](https://reactjs.org/docs/hooks-intro.html) 的实现,只能用于函数组件,class 组件请查看下面的例子。 ## en-US Call form method with `Form.useForm`. > Note that `useForm` is a [React Hooks](https://reactjs.org/docs/hooks-intro.html) that only works in functional component. ```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 => { switch (value) { case 'male': form.setFieldsValue({ note: 'Hi, man!' }); return; case 'female': form.setFieldsValue({ note: 'Hi, lady!' }); return; case 'other': form.setFieldsValue({ note: 'Hi there!' }); return; } }; const onFinish = values => { console.log(values); }; const onReset = () => { form.resetFields(); }; const onFill = () => { form.setFieldsValue({ note: 'Hello world!', gender: 'male', }); }; return (