这个是基于后端返回一个流文件后前端的处理
this.$http({
url: `/customer/export-ele-his?customerId=${this.formData.customerId}&startDate=${this.dateRange[0]}&endDate=${this.dateRange[1]}`,
method: 'get',
responseType: 'blob',
}).then(res => {
const url = window.URL.createObjectURL(new Blob([res]));
const link = document.createElement('a');
link.style.display = 'none';
link.href = url;
const fileName = '历史用能.xlsx';
link.setAttribute('download', fileName);
document.body.appendChild(link);
link.click();
this.$message.success('导出成功');
}).catch(() => {
this.$message.error('导出失败');
});