前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Antd for Vue使用Form组件报错You cannot set a form field before rendering的解决方法

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

作者头像
德顺
发布2023-08-25 12:42:36
5380
发布2023-08-25 12:42:36
举报
文章被收录于专栏:前端资源前端资源

使用 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 赋值时报错。

代码语言:javascript
复制
this.form.setFieldsValue({ //数据回显
  id: res.data.result.id,
  linkPhone: res.data.result.linkPhone,
});

报错的原因:

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

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

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

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-07-20),如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档