vue中axios下载文件失败,在catch中获取后端返回的报错信息并展示

if (err.config.responseType === 'blob') {
    const data = err.response.data;
    const reader = new FileReader();
    reader.onload = evt => {
       try {
          const resultObj = JSON.parse(evt.target.result);
          // resultOb是解码后的数据,然后再进行提示处理
       } catch (error) {}
    };
    reader.readAsText(data);
}

测试有效!!!

猜你喜欢

转载自blog.csdn.net/qq_38543537/article/details/131183747