1.3.5
win10, chrome, vue: 2.5.22
之前用的1.2.5没有问题,前几天更新到1.3.5后出现的(试过一直退到1.3.0都存在)
在调用 form.setFieldsValue 的时候会出现大量如下警告
“You cannot set a form field before rendering a field associated with the value.”
跟了一下发现是因为setFieldsValue的参数对象中含有表单不存在的属性时会出现警告
方法是 flattenRegisteredFields
因为使用场景一般是在编辑对象之前,从数据库加载后转json传回前端,调用此方法更新表单控件
所以参数中一般都比表单中的属性多
现在临时方案只能自己处理先调用 form.getFieldsValue 来对比去掉多余字段
请求采用1.2.5的方式,忽略不存在的字段
没有警告
警告 “You cannot set a form field before rendering a field associated with the value.”
暂时解决方案 使用 lodash.pick 库 可以过滤掉不用的对象属性。
我也遇到同样的问题,程序可以走的通,就是看着警告烦人。
建议手动过滤掉多余字段,之前版本有问题,漏掉了校验
that.form.setFieldsValue(that._.pick(rep.data, Object.keys(that.form.getFieldsValue())))
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
暂时解决方案 使用
lodash.pick库 可以过滤掉不用的对象属性。