vue 开发我的项目,遇到下载协定问题,已解决,和大家分享一下~
downloadHandle(){
let itemData = {ptojeatId:this.ptojeatId}
AgementList(this.ptojeatId).then(response => {let bob = new Blob([response],{type:'application/zip' ( 咱们后端下载个格局是 zip)
});
let objectUrl =URL.createObjectURL(blob);
location.href = objectUrl;
URL.revokeObjectURL(objectUrl);
}).catch(err => {console.log('下载谬误')
})
}
重点来了 调接口的时候要配置:export function(ptojeatId){
return request({
methods:'get',
url:"",
params:{ptojeatId:ptojeatId},
response:'arraybuffer'
})
}