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相关推荐

  1. 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 ...

  2. 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

  3. 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 ...

  4. #pragma warning(pop) 和 #pragma warning(push)的作用

    #pragma warning(push)是保存当前的编译器警告状态: #pragma warning(pop)是恢复原先的警告状态. 例如: #pragma warning( push ) #pra ...

  5. #pragma warning 启用和禁用warning

    开发人员可以使用 #pragma 指令将警告作为错误处理:还可以启用或禁用警告,如下面的示例所示: 1.将一个warning作为一个错误 #pragma warning (error: 6260) 2 ...

  6. C++ 中的 #pragma warning(push) 和 #pragma warning(pop)有什么用

    #pragma warning(push)是保存当前的编译器警告状态:  #pragma warning(pop)是恢复原先的警告状态. 例如:rocksdb中的一段代码 #if defined(_M ...

  7. 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 ...

  8. php 取消warning,php怎么关闭warning提示

    php怎么关闭warning提示2020-07-14 14:07:46 php关闭warning提示的方法是:可以通过error_reporting()函数来实现.error_reporting()函 ...

  9. LaTex warning:Package caption/hyperref Warning

    (1)报警告: ‪/usr/local/texlive/2022/texmf-dist/tex/latex/breakurl/breakurl.sty, 48‬ Package caption War ...

最新文章

  1. Shell引用-逻辑判断
  2. 如何判断浏览器的请求头是不是结束
  3. CentOs7中安装sonarQube服务系列------2.安装postgresSql数据库
  4. Freemarker模板引擎
  5. 手把手教你搭建 vue 环境
  6. [实战]MVC5+EF6+MySql企业网盘实战(12)——新建文件夹和上传文件
  7. 17.卷2(进程间通信)---后记
  8. 问题解决:AttributeError: 'module' object has no attribute '_rebuild_tensor_v2'
  9. mysql实现axure协同工作_Axure8利用Axure Share创建团队项目,进行多人协作开发
  10. 使用R语言制作树状图
  11. Linux下通过命令行登录北交校园网
  12. 胶囊网络可以PK掉CNN吗?//——暂时不能 胶囊网络的不足点思考
  13. 危化品爆炸场景下的应急通信系统解决方案
  14. 修改PyCharm的背景颜色
  15. 数据结构与算法第2章:链表
  16. 纯HTML+JS实现跑酷游戏
  17. 白帽,黑帽,灰帽,绿帽!一文了解黑客的所有信息
  18. Python的turtle库
  19. Linux下Oracle常见问题之Oracle ORA-01033 ORACLE initialization or shutdown in progress
  20. unity-unet-多人在线同步问题解决方案

热门文章

  1. 微信小程序波浪动态效果和背景色渐变(使用动态图,有手就行,但是流动速度固定波浪数目也固定)
  2. 即时通讯环信IM的集成使用
  3. SVM详解(一)线性可分支持向量机与硬间隔最大化
  4. Docker 磁盘空间使用分析与清理 解决磁盘空间不足
  5. cesium之三维场景展示篇
  6. MNIST手写数字识别程序
  7. python拿到股票代码和代码名称等基本信息
  8. 计算机技术考研科目大纲,2017计算机考研大纲:计算机大纲文字完整版
  9. 叶新伟 php,基于php+mysql技术bbs论坛设计的开发与实现最终版(样例3)
  10. win10xp化折腾指南