文件下载方案
<a> 标签下载
<a href="/path/to/file.pdf" download="custom-name.pdf">点击下载</a>function downloadFile(url, filename) {
const a = document.createElement('a');
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}使用 Blob + ObjectURL 下载
使用 DataURL 下载(适用于小文件或 Base64 内容)
第三方库
最后更新于