后台返回stream二进制数据流
const a = document.createElement('a');
a.download = '文件名' + '.xlsx';
a.style.display = 'none';
a.href = '下载地址';
document.body.appendChild(a)
a.click();
document.body.removeChild(a);
或者将href的地址作为一个接口来请求,请求的结果前端展示应该是一串乱码,将乱码用blob进行处理
const resFile = fileDown('参数')//fileDown为上面href中的地址接口,返回的resFile应该是乱码
//......同上
a.style.display = 'none';
const blob = new Blob([resFile],{type: 'application/vnd.ms-excel'})
a.href = URL.createObjectURL(blob)
//......同上