本文实例为大家分享了vue + axios下载文件的具体代码,供大家参考,具体内容如下
这里是axios的得到方法. post方法请点击这这里里=?/p>
<李> - type:“应用程序/x; charset=utf - 8”
李>
-
<李> responseType:“斑点”,
李>
<强>模板强>
& lt;按钮类=皁s_myProduct_td6Div5Btn2 @click.stop”=癲ownloadReport(项目、索引)”祝辞下载当天报表& lt;/button>
<强>脚本强>
方法:{ downloadReport(项目、索引){ 让日期=item.plans [this.daysIndex[指数]] 让url='/Ecp.Export.exportXls.jdn& # 63; entityId=' + item.FId +”,日期=' + date.FDeparture_date +”,令牌=' + sessionStorage.getItem(“令牌”) this.axios ({ 方法:“得到”, url: url、 responseType:“斑点”, }) 不要犹豫((数据)=比;{ 如果数据(!){ 返回 } 调试器 让url=window.URL.createObjectURL (data.data) 让链接=document.createElement (' a ') link.style。显示='没有' 链接。href=https://www.yisu.com/zixun/url 链接。setAttribute(“下载”,“excel.xls”) document.body.appendChild(链接) link.click () }) }, }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。