// 下载
const xxx = async () => {
try {
const response = await labPlanListxxx();
// 创建 Blob 对象
// 生成下载链接
const url = URL.createObjectURL(response);
// 创建 a 标签进行下载
const a = document.createElement('a');
a.href = url;
// 设置文件名,这里可以设置你需要的文件名
a.download = '导入模板.xlsx'; // 你可以使用 URL 编码的文件名
document.body.appendChild(a);
a.click();
// 清理
URL.revokeObjectURL(url);
document.body.removeChild(a);
} catch (e){
console.log('',e)
}
};
// 请求设置
export function labPlanListxxx (): any {
return axios({
url: '/api/template/download',
method: 'post',
responseType: 'blob', // 关键配置,指定响应类型为 Blob
})
}