再看那柔弱的柳树吧,在寒冬余威尚盛时节,就早早苏醒过来,望着冰冻的河面,迎着凛冽的寒风,它微微察觉出一丝春意,于是,不顾一切地率先吐翠,淡淡地披起娇黄嫩绿的新装。沿河望去,枝梢间烟纱雾彀,一片生机,这情景仿佛一首动人的歌,一首热烈向往春天的歌,一首报告春的信息的歌,一首表达美好信念的歌。我在想:既然迎春花被人称作报春花,那么,柳树可不可以叫作报春树呢春来了,万千柳枝在春风中袅袅舞动。柳树是热爱春天的,春天也是热爱柳树的。
本文实例为大家分享了vue + axios 下载文件的具体代码,供大家参考,具体内容如下
这里是axios的get方法。post方法请点击这里=》here
注意点:
Herder 请求头需注意
- content-disposition:”attachment;filename=total.xls”
- content-type:”application/x-download;charset=utf-8”
axios请求的responseType为blob
- responseType:'blob',
template
<button class="os_myProduct_td6Div5Btn2" @click.stop="downloadReport(item,index)">下载当天报表</button>
script
methods:{
downloadReport(item,index){
let date = item.plans[this.daysIndex[index]]
let url = '/Ecp.Export.exportXls.jdn?entityId='+item.FId+'&date='+date.FDeparture_date+'&token=' + sessionStorage.getItem("token")
this.axios({
method:'get',
url:url,
responseType:'blob',
})
.then((data) => {
if (!data) {
return
}
debugger
let url = window.URL.createObjectURL(data.data)
let link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', 'excel.xls')
document.body.appendChild(link)
link.click()
})
},
}
以上就是vue + axios get下载文件功能。当一个人选择成长的时候,往往也是选择不被人理解,因为你要走你选的路,不是他们认为你该选的路。更多关于vue + axios get下载文件功能请关注haodaima.com其它相关文章!




