weixin_44328461 2021-12-16 09:48 采纳率: 100%
浏览 1698
已结题

在修改数据后,点击提交,出现TypeError: Cannot read properties of undefined (reading 'result')的错误

问题遇到的现象和发生背景
 在修改数据后,点击提交,出现TypeError: Cannot read properties of undefined (reading 'result')的错误
问题相关代码,请勿粘贴截图
 var imgIds = this.fileList
        .map(item => {
          // console.log(item);  
          let fileType = this.matchType(item.response.result.s.fileName)           
          if(fileType == 'pdf'){
             return {
                    s:item.response.result.s?item.response.result.s.id:null,
                    see:item.response.result.see?item.response.result.see.arg:null
                    }
          }else{                   
              return false
          // return item.response.result.s.id
            }
        }
        ).filter(e=>e);
        if(imgIds.length > 0){
          values.imgIds = JSON.stringify(imgIds); 
        }
运行结果及报错内容
createBaseForm.js?6c71:617 TypeError: Cannot read properties of undefined (reading 'result')
    at eval (ShipUploadPage.vue?a6f6:762)
    at Array.map (<anonymous>)
    at eval (ShipUploadPage.vue?a6f6:759)
    at callback (createBaseForm.js?6c71:583)
    at Vue.validateFieldsInternal (createBaseForm.js?6c71:478)
    at eval (createBaseForm.js?6c71:610)
    at new Promise (<anonymous>)
    at Vue.validateFields (createBaseForm.js?6c71:571)
    at VueComponent.handleOk (ShipUploadPage.vue?a6f6:746)
    at invokeWithErrorHandling (vue.esm.js?efeb:1863)

我的解答思路和尝试过的方法
我想要达到的结果

修改后点击提交,显示修改成功

  • 写回答

3条回答 默认 最新

  • 心若向阳(* ̄︶ ̄) 2021-12-16 10:19
    关注

    一楼给你网,二楼是给你鱼和网,而我,只是一个去海边走走停停的人。(不管是拿数据、操作数据之前,先判断)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
  • 枫沂 2021-12-16 09:54
    关注

    以下都输出一下试试

    
     console.log(item);
     console.log(item.response);
    console.log(item.response.result);
    
    评论
  • 崽崽的谷雨 2021-12-16 09:57
    关注

    加个非空判断

    
      var imgIds = this.fileList
        .map(item => {
          // console.log(item);  
          if (item.response && item.response.result) { //加个 非空判断
            let fileType = this.matchType(item.response.result.s.fileName)
            if (fileType == 'pdf') {
              return {
                s: item.response.result.s ? item.response.result.s.id : null,
                see: item.response.result.see ? item.response.result.see.arg : null
              }
            } else {
              return false
              // return item.response.result.s.id
            }
          }
    
        }
        ).filter(e => e);
      if (imgIds.length > 0) {
        values.imgIds = JSON.stringify(imgIds);
      }
    
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 12月24日
  • 已采纳回答 12月16日
  • 创建了问题 12月16日

悬赏问题

  • ¥15 div editable中的光标问题
  • ¥15 mysql报错1415Not allowed to return a result set from a trigger 不知如何修改
  • ¥60 Python输出Excel数据整理,算法较为复杂
  • ¥15 回答几个问题 关于数据库
  • ¥15 51单片机串口通信问题,未完成且要修改
  • ¥15 百鸡问题 c++编程问题(相关搜索:输出数据)
  • ¥30 如何在CMD中设置代理
  • ¥15 我有一块薛定谔的硬盘
  • ¥15 微信小游戏开发2D碰撞检测问题
  • ¥30 MapReduce案例实践(实验过程需要截图加文字)