后端返回一个地址 让前端下载
function downloadFile(url, filename) {
var a = document.createElement('a');
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url); // 只允许访问一次,访问完就释放
}
// 在页面中使用
var fileUrl = 'https:xxx.pdf';
var fileName = 'test.pdf';
downloadFile(fileUrl, fileName);

浙公网安备 33010602011771号