文件下载

 download(data, fileName) {
      fileName = decodeURIComponent(fileName);
      console.log(data);
      if (!data) {
        this.$message.warning("文件下载失败")
        return;
      }
      // let url = window.URL.createObjectURL(new Blob([data]))
      let url = window.URL.createObjectURL(data.data);
      let link = document.createElement("a");
      link.style.display = "none";
      link.href = url;
      link.setAttribute("download", fileName);
      document.body.appendChild(link);
      link.click();
      //用于移除创建点击事件
      document.body.removeChild(link);
      window.URL.revokeObjectURL(url)
    },
posted on 2022-01-03 17:10  巨星太空易  阅读(34)  评论(0)    收藏  举报