结合Blob和OjbectURL实现更大的文件下载:

var a = document.createElement('a');
var txt = '.....content....';
for(var i=0;i<200;i++){
  txt = txt + txt;
}
var t = new Blob([txt], {type : 'application/csv'});
a.href=URL.createObjectURL(t)
a.download="filename.csv";
a.click();

用new Blob包装了我们的txt,然后通过createObjectURL去把Blob转换成对象地址,这样浏览器就可以下载很大的文件了。

相关文章:

  • 2021-09-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-13
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案