前端处理文件流(blob方式)下载文件
// 处理文件流
exportDocment(data, title) {
//data 文件流、title 导出名
let a = document.createElement('a');
a.download = title;
a.style.display = 'none';
let blob = new Blob([data],{type:'application/vnd.ms-excel'});
a.href = URL.createObjectURL(blob);
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
},

本文介绍了如何使用JavaScript的Blob对象处理文件流,通过创建隐藏的a元素并设置其download属性,实现Blob文件的下载。重点讲解了如何构造Blob实例并设置其类型,以及利用URL.createObjectURL技术实现文件下载的操作过程。
1万+

被折叠的 条评论
为什么被折叠?



