// downloadFile是你请求后端的接口
downloadFile().then((res) => {
const url = window.URL.createObjectURL(new Blob([res.data]));
const link = document.createElement("a");
link.style.display = "none";
link.href = url;
link.setAttribute("download", fileData.name);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
window.URL.revokeObjectURL(url);
});
js 下载后端接口返回的文件流
最新推荐文章于 2024-07-10 17:54:32 发布