let API='/gateway/cloud-dosp-manage/asset/index-config/exportIndexConfigLog' //后端给的接口
let link = document.createElement('a');
link.href =API + '?indexConfigId=' + this.itemData.id; //接口加上参数
link.click();
link.remove();
vue下载zip文件:
import { exportMethod } from '@/httpConfig/http.js';
let obj = {
method: "get",
url: '/gateway/cloud-dosp-manage/dosp/datadraw/dataDownload',
fileName: this.dataDownLoadList, //通过详情接口查出来文件名
params: {
applyId: this.formList.id,
checkCode: this.applyDownLoadForm.code,
}
}
exportMethod(obj);
http.js文件里:
export const exportMethod = function(data){
Axios({
method: data.method,
url: data.url,
params: data.params,
responseType: 'blob'
}).then((res) => {
const link = document.createElement('a');
let blob = new Blob([res], {type: 'application/zip'});
link.style.display = 'none';
link.href = URL.createObjectURL(blob);
link.class="download";
link.download = data.fileName //下载的文件名
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}).catch(error => {
this.$message.error(error.message);
})
};