let res = await fileDataDownloadIO({ id: downloadSelection });
const blob = new Blob([res.data], { type: res.data.type });
console.log("下载文件的值,", res);
const fileName = res.headers["content-disposition"].split(";");
const filename2 = fileName[1].split("=");
const filename3 = decodeURIComponent(filename2[1]);
let downloadElement = document.createElement("a");
let href = window.URL.createObjectURL(blob);
downloadElement.href = href;
downloadElement.download = filename3;
console.log("filename3", filename3);
document.body.appendChild(downloadElement);
downloadElement.click();
document.body.removeChild(downloadElement); //移除元素;防止连续点击创建多个a标签
window.URL.revokeObjectURL(href);
js下载 blob文件流
最新推荐文章于 2024-07-18 11:22:58 发布