vue + axios 通过Blob 转换excel文件流 下载乱码问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hefeng6500/article/details/82988624

首先看下我们接收到的请求:

 特别注意:responseType: 'blob'

    axios({
        method: 'GET',
        url: '/api',
        params: params,
        responseType: 'blob'
      }).then(res=>{
        let blob = new Blob([res.data], {type: "application/vnd.ms-excel"});
        let url = window.URL.createObjectURL(blob);
        window.location.href = url;
      }).catch(err=>{
        console.log(err)
      })

 参考:vue axios 请求二进制流excel文件,response乱码

vue + axios 通过blob 转换excel文件流 下载乱码问题

vue2.x 下载后台传过来的流文件(excel)后乱码问题(转载)

猜你喜欢

转载自blog.csdn.net/hefeng6500/article/details/82988624