admin管理员组

文章数量:1530027

后端获取的数据为blob格式的,结合a标签。

axios({

        method: "get",

        url: "/api/xxxx",

        params: { xxxx },

        responseType: "blob"

      }).then(res => {

        if (window.navigator.msSaveOrOpenBlob) {

          navigator.msSaveBlob(res.data, this.title);

        } else {

          const elink = document.createElement("a");

          elink.download = this.title;

          elink.style.display = "none";

          elink.href = URL.createObjectURL(res.data);

          document.body.appendChild(elink);

          elink.click();

          document.body.removeChild(elink);

        }

      });

本文标签: 可在浏览器文件方法手机