具体下载方式 ----
-----link = document.createElement("a")
-----link.download = fileName
-----link.href = href
-----link.click();
axios({
method: 'POST',
url: xxx,// 这里是后端的接口地址
responseType: 'blob',
data: "传输的数据",
})
.then(res => {
// 假设res表示后端发来的流数据
let blob = new Blob([res], {type: "application/msword"}), // 此处为生成doc
link = document.createElement("a"),
href = window.URL.createObjectURL(blob);
link.href = href;
link.download = "下载后文件的文件名";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
window.URL.revokeObjectURL(href); // 释放掉blob对象
})
vue 中使用blob导出,下载
最新推荐文章于 2024-06-06 10:02:08 发布