--- 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 React from 'react'; import { Button, Form, Mentions } from 'antd'; const { getMentions } = Mentions; const App: React.FC = () => { 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 (_: any, value: string) => { const mentions = getMentions(value); if (mentions.length < 2) { throw new Error('More than one must be selected!'); } }; return (
   
); }; export default App; ```