控制台报错信息
Uncaught Error: Must call `getFieldProps` with valid name string!
使用的是
const {getFieldDecorator} = this.props.form
<FormItem key={index} {...formItemLayout} label={item.name} hasFeedback > {getFieldDecorator(item.label, { initialValue: item.value, rules: [{ required: item.required, }], })( this.switchItem(item) )} </FormItem>
这里并不需要把getFieldDecorator替换成getFielProps。
我的报错原因是 表单的label(item.label)没有对应的字段,改成后端传过来的正确字段即可