答:可以通过使用 XMLHttpRequest 对象来下载文件,示例代码如下: var xhr = new XMLHttpRequest(); xhr.open('GET', 'url-to-file', true); xhr.responseType = 'blob'; xhr.onload = function(e) { if (this.status == 200) { // get binary data as a response var blob = this.response; } }; xhr.send();
简单的前端下载文件脚本
最新推荐文章于 2024-06-12 11:13:48 发布