javascript – 使用带有redux-form的antd

前端之家收集整理的这篇文章主要介绍了javascript – 使用带有redux-form的antd前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用我的redux-form使用ant.design react组件,到目前为止它是这样的: @H_502_2@import { Form,Input } from 'antd'; import { Field,reduxForm } from 'redux-form/immutable'; const FormItem = Form.Item; ..... <FormItem> <Field component={Input} placeholder="First Name" name="name" /> </FormItem>

似乎antd表单输入不支持name属性,它们忽略并阻止将其传递下去.

redux-form需要name属性才能工作.

有没有人成功让这两个人一起工作?谢谢.

解决方法

除了Maxim的回答之外,我还必须将r​​edux-form props.input comp传递给antd Input组件. @H_502_2@const NewInput = ({ label,labelCol,wrapperCol,help,extra,validateStatus,hasFeedback = true,colon,...rest }) => { return (<FormItem label={label} wrapperCol={wrapperCol} labelCol={labelCol} help={help} hasFeedback={hasFeedback} extra={extra} validateStatus={validateStatus} colon={colon} > <Input {...rest.input} /> </FormItem>); };

猜你在找的JavaScript相关文章