axios({
url: 'http://localhost:5000/pd_download',
method: 'post',
data: {id},
responseType: 'blob'
}).then((res) => {
console.log(res);
const blob = new Blob([res.data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"});
const elink = document.createElement("a");
elink.download = `文档.docx`;
elink.style.display = "none";
elink.href = URL.createObjectURL(blob);
document.body.appendChild(elink);
elink.click();
URL.revokeObjectURL(elink.href); // 释放URL 对象
document.body.removeChild(elink);
});
如题,在没有封装的情况下简单发送请求并下载