Laden Sie Dateien per Vue-Stream herunter

Nachdem ich den Stream erhalten habe

downloadFn(){
    
    
	// res.data返回的流
	const blob = new Blob([res.data],{
    
    type:'application/octet-stream'});
	const fileName = '导出文件.zip';
	const Url = window.URL|| window.webkitURL;
	if('download' in document.createElement('a')){
    
     //非ie下载
		const elink = document.createElement('a');
		elink.download = download;
		elink.style.display = 'none';
		elink.href = URL.createObjectURL(blob);
		document.body.appendChild(elink);
		elink.click();
		URL.revokeObjectURL(elink.href);
		document.body.removeChild(elink);
	}else {
    
     // ie10下载
		navigator.msSaveBlob(blob,download)
	}
}

Guess you like

Origin blog.csdn.net/weixin_43979503/article/details/125547560