后端返回的文件流,前端如何下载

时间:2025-03-28 10:10:32

首先配置axios


// 下载公用方法
const reqDown = (method, url, params) => {
  return axios({
    method: method,
    url:  + url,
    responseType: 'blob',
    data: params
  }).then(res => );
};

然后在调用接口后


          let blob = new Blob([res], {
            type: "application/-excel"    // 这边的类型需要改
          });
          let url = (blob)
          let link = ('a')
           = 'none'
           = '意见箱'  //  这边的名字需要改
           = url
          (link)
          ()