后台返回的的是
download: (data) => {
const url = `/acloud-file-center/resourceAccess/download`
return request({
url: url,
method: 'get',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
responseType: "blob",
params: {
fileId: data
}
})
}, // 下载
接口返回处理
handlePreview (file) {
let fileName = file.name ? file.name : file.response.data.filename
let url = file.fileid ? file.fileid : file.response.data.fileid
api.download(url).then(res => {
const blob = new Blob([res], { type: res.type });
const eLink = document.createElement("a");
eLink.download = fileName;
eLink.style.display = "none";
eLink.href = URL.createObjectURL(blob);
document.body.appendChild(eLink);
eLink.click();
const a = URL.revokeObjectURL(eLink.href); // 释放
})
},
完美解决