导出:Uncaught (in promise) Blob {size: 776, type: "

导出压缩包报错:Uncaught (in promise) Blob {size: 776, type: "application/octet-stream"}

接口返回:

报错:

 

描述:后端返回的数据是能正常使用的,因为其他接口是这样的返回方式,然后下载成功。我现在接一个另一个下载接口,不知道为什么就报错。

相关代码:

// 请求导出
      const res = await exportEvent({ idList: resultList })
      debugger
      console.log('res', res)
      if (
        typeof res.data === 'object' &&
        res.data.type === 'application/json'
      ) {
        const reader = new FileReader()
        reader.onload = e => {
          const info = JSON.parse(e.target.result)
          this.$message.warning(`导出失败:${info.errmsg}`)
        }
        debugger
        reader.readAsText(res.data)
        return false
      }
      // 构造一个blob对象来处理数据
      const blob = new Blob([res.data], { type: 'application/zip' })
      // 拼接文件名称
      const fileName = `${this.checkedRow[0].appKey}${
        this.checkedRow[0].systemYear
      }N
      ${this.checkedRow.length}_${moment(new Date()).format('YYYYMMDD')}`
      debugger
      const href = URL.createObjectURL(blob)
      debugger
      navigateTo(`${href}`, 'donwload', { fileName })
      debugger
      URL.revokeObjectURL(href)
      debugger
      this.rowSelection.selectedRowKeys = []
      this.checkedRow = []

接口封装:

上面的相关代码,第二行的debugger都没跑到,就跑到第一行就报我的错了,这怎么解决啊呜呜呜呜呜呜

你用的是什么请求,有异常捕获吗,catch(err){} 可能原因https://blog.csdn.net/qq_22701869/article/details/107816023 和https://bbs.csdn.net/topics/396525243