- 问题:文件下载,后台返回的数据是二进制流
// 使用axios,从后台获取文件二进制流
axios({
url:url,
responseType:'arraybuffer'
}).then((res)=>{
if (!res) return;
let aurl = window.URL.createObjectURL(
new Blob([res], { type: "application/octet-stream" })
);
let link = document.createElement("a");
link.style.opacity = "0";
link.href = aurl;
link.setAttribute("download", fileName);
let aP = this.$refs.inputwrap;
aP.appendChild(link);
link.click();
link.remove();
})