This is based on the processing of the front end after the back end returns a stream file
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('导出失败');
});