响应拦截 blob 格式 处理

51 阅读1分钟
 var blob = error.response.data;
  if (blob && blob.type && blob.type.indexOf("application/json")>-1) {
    //方式一:使用Blob.text(),参考https://developer.mozilla.org/zh-CN/docs/Web/API/Blob/text
    blob.text().then(text => {
      if (typeof (text) == 'string') {
          //服务端响应信息就在 errInfo
          //然后弹出报错信息  
          Message({
            message: text,
            type: 'error',
            duration: 1500,
            customClass: 'element-error-message-zindex'
          })
      }
    })
    return;
  }