同一个js中写了多张form表单,数据如何传出,也就是getFieldProps怎么绑定

  const { getFieldProps } = this.props.form;
 const { getFieldProps2 } = this.props.form2;
return(
<Form inline form={this.props.form} onSubmit={this.handleActivitySearch}>
...
 <Input style={{}} type="text" placeholder="" {...getFieldProps('userID', {initialValue: '' })} />
</Form>
<Form inline form={this.props.form2} onSubmit={this.handleActivitySearch}>
 <Input style={{}} type="text" placeholder="" {...getFieldProps2('userID', {initialValue: '' })} />
...
</Form>
);
这里怎么获取这两个表单的数据?上面的做法是被报错的,会提示getFieldProps2 未定义
阅读 8.6k
2 个回答

const { getFieldProps } = this.props.form; 这句的意思是form中的getFieldProps方法,form和它的方法是固定的,因此并没有form2这个东西,也就没有getFieldProps2 。建议尝试一下getFieldProps = this.props.form.getFieldProps ,然后直接使用form={getFieldProps }。我也是初学,哈哈,有什么说得不对的告诉我,我改正哈
可以参考蚂蚁UI的form: http://ant.design/components/...,里面有form里面的方法介绍

我也遇到题主的问题了,最后解决方案是把每个表单单独用一个组件

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题