//下载接口请求
async downloadSend(row) {
//row中是表格中的某条数据
let req = {
id: row.id,
};
var { data } = await Download(req);
this.downloads(data, row);
},
// 下载文件
downloads(data, row) {
//下载的文件名
let fileName = row.full_path.split("/");
if (!data) {
return;
}
let url = window.URL.createObjectURL(new Blob([data]));
let link = document.createElement("a");
link.style.display = "none";
link.href = url;
//设置下载的文件名
link.setAttribute("download", fileName[fileName.length - 1]);
document.body.appendChild(link);
link.click();
},
我下载下来是乱码的,然后试着给请求头中增加了{responseType: 'blob'},然后就可以了