随笔- 14  文章- 0  评论- 0  阅读- 10184 

下载:

axios({
    url: `url`,
    method: "post",
    data: {
     参数...
    },
    responseType: "blob",
  })
.then((res)=>{
  const link = document.createElement("a");
      let blob = new Blob([res.data], { type: "application/vnd.ms-excel" });
      link.style.display = "none";
      link.href = URL.createObjectURL(blob);
      link.download = "下载文档" + ".xls"; //下载的文件名
      document.body.appendChild(link);
      link.click();
      document.body.removeChild(link);
})
预览:
axios({
    url: `url`,
    method: "post",
    data: {
     参数...
    },
    responseType: "blob",
  })
.then((res)=>{
 const blob = new Blob([response], { type: "application/pdf" });
    const href = window.URL.createObjectURL(blob);
    window.open(href);
})
 posted on   久闻  阅读(87)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
点击右上角即可分享
微信分享提示