Antd for Vue使用Form组件报错You cannot set a form field before rendering的解决方法

使用 Antd for Vue 的 setFieldsValue 赋值时报错:warning.js?4eb8:34 Warning: You cannot set a form field before rendering a field associated with the value. You can use `getFieldDecorator(id, options)` instead `v-decorator="[id, options]"` to register it before render.

报错的场景:

页面编辑时,获取接口数据,进行回显。

使用 setFieldsValue 给 v-decorator 赋值时报错。

this.form.setFieldsValue({ //数据回显
  id: res.data.result.id,
  linkPhone: res.data.result.linkPhone,
});

报错的原因:

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

这里,多传递了多余的字段,自己检查一下,看看是否传递了页面中没有的字段。


未经允许不得转载:Web前端开发资源网 » Antd for Vue使用Form组件报错You cannot set a form field before rendering的解决方法

推荐阅读:

jquery导航栏点击及页面跳转后对应栏目添加选中效果

判断网页是通过PC端还是移动终端打开的

2018年4月24日 服务器换成腾讯云

PHP连接MySQL数据库报错:Call to undefined function mysql_connect()的解决方法

jQuery实现本地input选择图片实时显示

赞 (4)
分享到: +

评论 沙发

Avatar

换个身份

  • 昵称 (必填)
  • 邮箱 (选填)