warning.js?d96e:34 Warning: You cannot set a form field before rendering a field associated with the
warning.js?d96e: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.
在接口返回数据后,给动态表单复制遇到个这么个问题,第一次点编辑时,会报下图中的错误,但第二次点击编辑就不报错了,之后也是正常的。
解决:首先保证表单返回数据与注册数据都对应,给表单赋值放在了this.$nextTick,这两点没没问题了,可以往下看了。
部分代码:
edit(record) {this.editId = record.Idthis.form.resetFields()//第二种办法:先注册keys// this.form.getFieldDecorator('keys', { initialValue: [0], preserve: true })this.modalState = '编辑'this.requestGet('/Examtion/GetExamtionById', { id: this.editId }).then((res) => {console.log(res.data.QuestionTemplateList.map((item) => {return {QuestionStyle: item.QuestionStyle,QuestionNum: item.QuestionNum,Score: item.Score,}}))const validTime = [moment(res.data.StartTime, 'YYYY-MM-DD HH:mm:ss'),moment(res.data.EndTime, 'YYYY-MM-DD HH:mm:ss'),]const TreeIds = res.data.Regions.length == 0 ? [] : res.data.Regions[0].TreeIds.split(',')if (TreeIds.length == 0) {} else {TreeIds.splice(0, 2)}// 第一种办法:初始化keys值this.form.getFieldDecorator('keys', {initialValue: res.data.QuestionTemplateList.map((item, index) => index),preserve: true, //即便字段不再使用,也保留该字段的值})//第二种办法:再给keys赋值,this.visible = true写在哪里就都可以了// this.form.setFieldsValue({// keys: res.data.QuestionTemplateList.map((item, index) => index),// })id = res.data.QuestionTemplateList.length//第一种办法:关键点是这里在表单赋值前,令this.visible = true,也就是modal 弹出this.visible = truethis.$nextTick(() => {this.form.setFieldsValue({// keys:res.data.QuestionTemplateList.map((item, index) => index),ExamtionName: res.data.ExamtionName,GrossScore: res.data.GrossScore,ExamtionDuration: res.data.ExamtionDuration,QualifiedScore: res.data.QualifiedScore,Version: res.data.QuestionTemplateList[0].QuestionVersons,RegionId: TreeIds,validTime: validTime,// Json: res.data.QuestionTemplateList.map((item) => {// return {// QuestionStyle: item.QuestionStyle,// QuestionNum: item.QuestionNum,// Score: item.Score,// }// }),QuestionNum: res.data.QuestionTemplateList.map((item) => item.QuestionNum),})})})},
完美解决!欢迎大佬指正!
warning.js?d96e:34 Warning: You cannot set a form field before rendering a field associated with the相关推荐
- warning.js?d96e:34 Warning: `getFieldDecorator` will override `value`, so please don‘t set `value`
warning.js?d96e:34 Warning: getFieldDecorator will override value, so please don't set value directl ...
- warning.js:7 Warning: [antdv: Table] Each record in dataSource of table should have a unique `key`
warning.js:7 Warning: [antdv: Table] Each record in dataSource of table should have a unique key
- antd From 表单报错:warning.js:6 Warning: [antd: Switch] value is not validate prop, do you mean checke?
同样的是适用于Checkbox组件 在使用 antd 时,form 表单中使用 switch 报错: warning.js:6 Warning: [antd: Switch] value is not ...
- #pragma warning(pop) 和 #pragma warning(push)的作用
#pragma warning(push)是保存当前的编译器警告状态: #pragma warning(pop)是恢复原先的警告状态. 例如: #pragma warning( push ) #pra ...
- #pragma warning 启用和禁用warning
开发人员可以使用 #pragma 指令将警告作为错误处理:还可以启用或禁用警告,如下面的示例所示: 1.将一个warning作为一个错误 #pragma warning (error: 6260) 2 ...
- C++ 中的 #pragma warning(push) 和 #pragma warning(pop)有什么用
#pragma warning(push)是保存当前的编译器警告状态: #pragma warning(pop)是恢复原先的警告状态. 例如:rocksdb中的一段代码 #if defined(_M ...
- php date 有warning,php提示PHP Warning: date(): It is not safe to rely on the......错误的解决办法...
在写php程序中有时会出现这样的警告: PHP Warning: date(): It is not safe to rely on the system's timezone settings. Y ...
- php 取消warning,php怎么关闭warning提示
php怎么关闭warning提示2020-07-14 14:07:46 php关闭warning提示的方法是:可以通过error_reporting()函数来实现.error_reporting()函 ...
- LaTex warning:Package caption/hyperref Warning
(1)报警告: /usr/local/texlive/2022/texmf-dist/tex/latex/breakurl/breakurl.sty, 48 Package caption War ...
最新文章
- Shell引用-逻辑判断
- 如何判断浏览器的请求头是不是结束
- CentOs7中安装sonarQube服务系列------2.安装postgresSql数据库
- Freemarker模板引擎
- 手把手教你搭建 vue 环境
- [实战]MVC5+EF6+MySql企业网盘实战(12)——新建文件夹和上传文件
- 17.卷2(进程间通信)---后记
- 问题解决:AttributeError: 'module' object has no attribute '_rebuild_tensor_v2'
- mysql实现axure协同工作_Axure8利用Axure Share创建团队项目,进行多人协作开发
- 使用R语言制作树状图
- Linux下通过命令行登录北交校园网
- 胶囊网络可以PK掉CNN吗?//——暂时不能 胶囊网络的不足点思考
- 危化品爆炸场景下的应急通信系统解决方案
- 修改PyCharm的背景颜色
- 数据结构与算法第2章:链表
- 纯HTML+JS实现跑酷游戏
- 白帽,黑帽,灰帽,绿帽!一文了解黑客的所有信息
- Python的turtle库
- Linux下Oracle常见问题之Oracle ORA-01033 ORACLE initialization or shutdown in progress
- unity-unet-多人在线同步问题解决方案