技术就餐

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

后端返回二进制excel,如何下载

  axios({
        url:
          config.Urls.serverUrl + "/load/airdoc/result/export/getAppraisalData",
        method: "POST",
        responseType: "blob",
        data: param,
      }).then((res) => {
        // console.log(res.data);
        let date = new Date();
        let y = date.getFullYear();
        let m = date.getMonth() + 1;
        let d = date.getDate();
        let result = res.data; //如果后端返回的result是进过Blob处理的,直接 window.URL.createObjectURL(result),如果没有,就需要先实例化new Blod处理之后再window.URL.createObjectURL(blob)。
        let blob = new Blob([result], { type: "application/vnd.ms-excel" });
        let url = window.URL.createObjectURL(blob);
        let link = document.createElement("a");
        link.download = y + "-" + m + "-" + d + "身心健康屏企业报告";
        link.href = url;
        link.click();
      });

posted on   技术就餐  阅读(89)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
· 因为Apifox不支持离线,我果断选择了Apipost!
点击右上角即可分享
微信分享提示