// 下载
async download() {
axios({
method: "get",
url: ``, // 接口
responseType: "blob",
}).then((res) => {
if (!res) {
return this.$message.info("网络错误或下载失败!");
}
let blob = new Blob([res.data], {
type: "applicationnd.openxmlformats-officedocument.wordprocessingml.document", //doc格式
});
let contentDisposition = res.headers["filename"];
let fileName = window.decodeURI(
contentDisposition.substring(contentDisposition.indexOf("=") + 1)
);
let url = window.URL.createObjectURL(blob);
let link = document.createElement("a");
link.style.display = "none";
link.href = url;
link.setAttribute("download", fileName);
document.body.appendChild(link);
this.$message.success("下载成功");
link.click();
});