返回的数据流带入function中即可,可修改文件名称
function getOutExcel(fileName, res) { let blob = new Blob([res], { type: "application/vnd.ms-excel" }); if (window.navigator.msSaveOrOpenBlob) { navigator.msSaveBlob(blob, fileName); } else { var link = document.createElement("a"); const url = window.URL || window.webkitURL || window.moxURL; link.href = url.createObjectURL(blob); link.download = fileName; link.click(); url.revokeObjectURL(link.href); } } getOutExcel("文件名称", res);