企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[toc] ## Form.create()() 返回一个高阶组件,向原本的组件传递一些属性,用来设置表单字段的值 和获取值 ``` const WrappedLoginForm = Form.create({})(LoginForm); ``` ## getFieldDecorator ``` const FormItem = Form.Item ``` ``` const {getFieldDecorator} = this.props.form ... <FormItem> { getFieldDecorator('username',{ rules:[{required:true,message:'请输入用户名'}] })(<Input placeholder="用户名">) } </FormItem> ``` ## validateFields ![](https://box.kancloud.cn/145b8814d60b5e26e9bde15afed92392_707x244.png) ``` class Login extends Component{ handleSubmit = (event)=>{ event.preventDefault(); this.loginForm.props.form.validateFields((err,values)=>{ if(err){ message.warn(err.toString()); }else{ this.props.dispatch({ type:'login/login' ,payload:values }); } }); } } ```