背景说明:
请求接口返回一个url地址,使用a标签下载,但是名字已经通过url定义好了
需求说明:
要求名字前端定义
queryNotice () {
const params = { ... };
this.axiosPost('/xxserver/...', params).then(
(res) => {
const a = document.createElement("a");
const url =res.data;
fetch(url).then((res) => res.blob()).then((blob) => {
// 将链接地址字符内容转变成blob地址
a.href = URL.createObjectURL(blob);
a.download = 'XXXXX.docx'; // 下载文件的名字
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
})
}
)