文件下载功能
// 模板下载
export const modelLoadInterface = (data: any) => {
return get<Response>('tsureexapp-exchange/config/points/grant/export.json', data, {
skipErrorHandler: true,
});
};
import {modelLoadInterface} from "@/services/CommunicationField";
modelLoadInterface().then((res) => {
// res是图一,有的可能包了 data,看后台怎么返给你的
const url = window.URL.createObjectURL(new Blob([res]))
const link = document.createElement('a')
link.href = url
link.setAttribute('download', '999.xlsx') //后缀名可自行更改
link.click()
window.URL.revokeObjectURL(url)
}).catch((err) => {
console.log(err)
})
图一
图二(文件流)