流浪のwolf

卷帝

导航

前端导出excel文件,后端返回二进制文件 application/octet-stream 前端处理数据并下载excel文件

通过URL.createObjectURL(blob)可以获取当前文件的一个内存URL

 

  const href = URL.createObjectURL(res.data);
              const box = document.createElement('a');
              console.log(res.filename);
              var name = res.filename.replace('filename=', '').trim();
              box.download = name;
              box.href = href;
              box.click();

URL.createObjectURL 的使用方法 - 流浪のwolf - 博客园 (cnblogs.com)

posted on 2024-07-05 10:52  流浪のwolf  阅读(1)  评论(0编辑  收藏  举报