原文:https://www.cnblogs.com/zhang-can/p/9116159.html
vue下载文件
download(){
  let self = this;
  let url = self.$store.state.path + "tools/download_file";
  let data = JSON.stringify({
    user: self.$store.state.username,
    file_name: self.plist_file_name
  });
  console.log("data:", data)
  self.$axios(
    {
      method: "post",
      url: url,
      data: data,
      responseType: "blob",    // 指定获取数据的类型为blob
    }
  ).then(
    function (response) {
      data = response.data;
      // 创建a标签并点击, 即触发下载
      let url = window.URL.createObjectURL(new Blob([data]));
      let link = document.createElement("a");
      link.style.display = "none";
      link.href = url;
      link.setAttribute("download", self.plist_file_name);
      document.body.appendChild(link);
      link.click()
    }
  ).catch(function (err) {
    console.log(err)
  })
}
来源:CSDN
作者:不屑哥
链接:https://blog.csdn.net/fuck487/article/details/103627899