// 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年
等级:
文章:631
访问:52336
博客简介:DongJiang的博客
博客创建时间:2018-04-12
给博主送颗小红心
1002
后台管理系统: 进入后台

使用JS实现文件下载代码

      // 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();
原文出处:
版权声明:本文来源地址若非本站均为转载,若侵害到您的权利,请及时联系我们,我们会在第一时间进行处理。