/** * 用于导出Excel流文件 * @param {string} url - 接口地址; body - 参数; text - 文件名 */ public exportExcel(url ?: any, body ?: any, text ?: string) { this.$axios.request({ method: 'get', url, data: body, responseType: 'blob' }).then(res => { console.log(res); const result = res.data; const herfs = window.URL.createObjectURL(new Blob([result])); const link = document.createElement('a'); link.style.display = 'none'; link.href = herfs; link.setAttribute('download', `${text}.xlsx`); document.body.appendChild(link); link.click(); document.body.removeChild(link); // 移除blob对象的url window.URL.revokeObjectURL(url); }).catch(err => { this.$message.error(err.message); }); }