2024年07月27日 建站教程
注:ajax中加responseType: "blob"
if (res && res.status === 200) { const filename = "对账表.xlsx"; const blob = new Blob([res.data]); const link = document.createElement("a"); link.style.display = "none"; link.href = URL.createObjectURL(blob); link.setAttribute("download", filename); document.documentElement.appendChild(link); link.click(); document.documentElement.removeChild(link); } else { let content = res.data; //arraybuffer类型数据 let resBlob = new Blob([content]); let reader = new FileReader(); reader.readAsText(resBlob, "utf-8"); reader.onload = () => { _this.$message.error(reader.result); }; }
本文链接:http://so.lmcjl.com/news/9276/