h5 通过axios下载文件 适合各种文件类型
downloadFile(url , name , headers = {} , param = {}){
let paramAll = Object.assign({_cache:Date.now()} , param);
axios.get(url , {
headers,
responseType:'blob', // important
params:paramAll
}).then((response)=>{
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download',name);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
})
},