ajax拦截blob错误

 if (error.response.config.responseType === 'blob') {
        const blob = new Blob([error.response.data])
        const res = await uploadFile(blob)
        Message({
          message: JSON.parse(res).message || '未知错误,请稍后重试',
          type: 'error',
          duration: 5 * 1000,
          showClose: 'true'
        })
      } 
function uploadFile(file) {
  return new Promise(function(resolve, reject) {
    const reader = new FileReader()
    reader.readAsText(file, 'utf-8')
    // onload 是异步
    reader.onload = function() {
      // return reader.result
      resolve(reader.result)
    }
  })
}


版权声明:本文为cherry_zhang18原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。