前端下载——处理后端返回的二进制文件(乱码)
https://blog.csdn.net/heixiuheixiu666/article/details/105734283?utm_medium=distribute.pc_relevant.none-task-blog-OPENSEARCH-7.compare&depth_1-utm_source=distribute.pc_relevant.none-task-blog-OPENSEARCH-7.compare
//导出 excelOut() { this.axios .get(url, { responseType: 'blob' }) .then(res => { let url = window.URL.createObjectURL(res) let a = document.createElement('a') document.body.appendChild(a) a.href = url const fileName = '文件名.xlsx' a.download = fileName a.click() window.URL.revokeObjectURL(url) }) .catch(() => { this.$message.error('导出失败') }) }