当前端收到后端传过来的数据流时,前端文件下载方法:
let url = window.URL.createObjectURL(new Blob([res.body])); let link = document.createElement('a'); link.style.display = 'none'; link.href = url; link.setAttribute('download', res.response.headers['content-disposition'].split('=')[1]); // 设置下载文件名称 link.click(); link.remove();
标签:url,res,前端,link,数据流,下载 From: https://www.cnblogs.com/maxiaocang/p/17162753.html