js文件下载,返回blod
/*** blob文件下载* @param {} blob 流文件* @returns*/
function downloadBlobFile(blob, filename) {if (!blob) returnconst url = window.URL.createObjectURL(new Blob([blob], {}))triggerDownload(url, filename)
}
function triggerDownload(url, filename) {// 创建隐藏的可下载链接const link = document.createElement('a')link.style.display = 'none'link.href = urlif (filename) {link.setAttribute('download', filename)}// 触发点击document.body.appendChild(link)link.click()// 然后移除document.body.removeChild(link)
}