--- order: 2 title: zh-CN: 配合 Form 使用 en-US: With Form --- ## zh-CN 受控模式,例如配合 Form 使用。 ## en-US Controlled mode, for example, to work with `Form`. ```tsx import { Mentions, Form, Button } from 'antd'; const { Option, getMentions } = Mentions; const App = () => { const [form] = Form.useForm(); const onReset = () => { form.resetFields(); }; const onFinish = async () => { try { const values = await form.validateFields(); console.log('Submit:', values); } catch (errInfo) { console.log('Error:', errInfo); } }; const checkMention = async (rule, value, callback) => { const mentions = getMentions(value); if (mentions.length < 2) { throw new Error('More than one must be selected!'); } }; return (
   
); }; ReactDOM.render(, mountNode); ```