export const downloaddata = (params) => http({
url: Api + ‘接口’,
params,
responseType: ‘blob’ // 要定义这个blob
});
// 接口
downloaddata(a).then(res => {
const blob = res.data;
let url = window.URL.createObjectURL(blob);
const link = window.document.createElement(‘a’); // 创建a标签
link.href = url;
link.download = ‘twitter-’ + Date.now() + ‘.zip’; //设置文件名
link.style.display = ‘none’;
link.click();
URL.revokeObjectURL(url); // 释放内存
this.$message({
type: ‘success’,
message: ‘批量下载成功’
});
})
vue 下载zip压缩包
最新推荐文章于 2024-07-23 15:29:26 发布