乱码乱a∨中文字幕,在线免费激情视频,亚洲欧美久久夜夜潮,国产在线网址

  1. <sub id="hjl7n"></sub>

    1. <sub id="hjl7n"></sub>

      <legend id="hjl7n"></legend>

      當前位置:首頁 >  站長 >  編程技術 >  正文

      設置了responseType:Blob之后,如果返回json錯誤信息,如何獲???

       2020-11-05 14:30  來源: 田珊珊個人博客   我來投稿 撤稿糾錯

        阿里云優(yōu)惠券 先領券再下單

      當我們將請求類型設置為responseType: ‘blob’時,什么是Blob呢,MDN官方解釋:Blob 對象表示一個不可變、原始數(shù)據(jù)的類文件對象。我們會發(fā)現(xiàn)正常獲取錯誤信息返回時,拿不到錯誤信息,但是在控制臺可以正??吹?,這時我們需要將錯誤信息處理一下。

      請求設置:

      async getExperienceQRCode(formDate) {

      return await $axios.$post(`/admin/wx-open-platform/qrcode`,JSON.stringify(formDate),{ responseType: 'blob'})

      },

      錯誤返回處理:

      if (error.response.request.responseType && error.response.request.responseType == 'blob')

      {

      let reader = new FileReader()

      reader.onload = e => {

      let errData = JSON.parse(e.target.result)

      Vue.prototype.$message.error(errData.data);

      }

      reader.readAsText(error.response.data)

      }

      文章來源:田珊珊個人博客

      來源地址:http://www.tianshan277.com/849.html

      申請創(chuàng)業(yè)報道,分享創(chuàng)業(yè)好點子。點擊此處,共同探討創(chuàng)業(yè)新機遇!

      相關文章

      熱門排行

      信息推薦