// create URL and Link const url = window.URL.createObjectURL(blob); const a = document.createElement("a"); a.href = url; a.download = filename; document.body.appendChild(a); // Invoke download a.click(); // remove URL and Link window.URL.revokeObjectURL(url); a.remove(); " />
博主:DongJiang
码龄:7年
等级:LV.22级
文章:631
访问:5233623
博客简介:记录与分享
博客创建时间:2018-04-12
他的博客主页 立即前往

友情链接

使用JS实现文件下载代码

来源: 2023-06-22 18:21:51
      // create URL and Link
      const url = window.URL.createObjectURL(blob);
      const a = document.createElement("a");
      a.href = url;
      a.download = filename;
      document.body.appendChild(a);

      // Invoke download
      a.click();

      // remove URL and Link
      window.URL.revokeObjectURL(url);
      a.remove();
原文出处:
版权声明:本文来源地址若非本站均为转载,若侵害到您的权利,请及时联系我们,我们会在第一时间进行处理。