setFieldsValue报错You cannot set a form field before rendering a field associated with the value

You cannot set a form field before rendering a field associated with the value.
报错语句的含义:在呈现与该值关联的字段之前,不能设置表单字段值。

this.props.form.setFieldsValue这个方法里面传值的时候只能是form中用到的参数(即是getFieldDecorator方法中的field)没有的field一律不允许多传,否则就会报错。

报错事例如下:
刚开始select1的值是无,select2被隐藏,之后每次修改select1,就重新把select2的值清空,这样就导致 form中还没有select2这个表单字段就给它做了一遍清空操作,所以就报错了。。

解决这个提前清空的操作就可以了。
setFieldsValue报错You cannot set a form field before rendering a field associated with the value_第1张图片

你可能感兴趣的:(前端UI,antd,form,setFieldsValue)