vue后台管理系统,导出功能
直接上代码
exportData(){ let urlstr = "/StatisticalAnalysis/exportAreaTargetStatistical" if(this.beginTime != "" && this.endTime != ""){ urlstr=urlstr+"?b="+this.beginTime+"&e="+this.endTime; } this.$axios.get(urlstr,{responseType: 'blob'}).then((response) => { console.log(JSON.stringify(response)) const blob = new Blob([response.data]); //const fileName = response.headers['content-disposition'] //下载后文件名 const fileName = '区域可疑目标统计.xls'; const linkNode = document.createElement('a'); linkNode.download = fileName; //a标签的download属性规定下载文件的名称 linkNode.style.display = 'none'; linkNode.href = URL.createObjectURL(blob); //生成一个Blob URL document.body.appendChild(linkNode); linkNode.click(); //模拟在按钮上的一次鼠标单击 URL.revokeObjectURL(linkNode.href); // 释放URL 对象 document.body.removeChild(linkNode); }) }