js通过url链接下载文件
情景说明
ajax请求后, 后端的导出接口, 返回的是导出文件的url链接
实现
const elt = document.createElement('a');
elt.setAttribute('href', url);
elt.setAttribute('download', 'file.png');
elt.style.display = 'none';
document.body.appendChild(elt);
elt.click();
document.body.removeChild(el
原创
2022-02-10 18:14:09 ·
2426 阅读 ·
0 评论