export function downloadKnowledage(parameter) {
return axios({
url: '/knowledage/download',
method: 'GET',
params: parameter,
responseType: 'blob'
})
}
添加 responseType: 'blob’解决以下乱码现象
使用触发a标签下载文件
downloadKnowledage(data).then((res) => {
let link = document.createElement("a");
link.href = window.URL.createObjectURL(
new Blob([res.data], {
type: "application/octet-stream;charset=UTF-8",
})
);
link.setAttribute("download", file_name);
document.body.appendChild(link);
link.click();
link.remove();
});