前端JS接收服務端的二進位制檔案流實現檔案下載
阿新 • • 發佈:2020-12-18
技術標籤:javascriptjs
前端JS接收服務端的二進位制檔案流實現檔案下載
var binaryData = []; binaryData.push(res); // 改成Boole或者file型別 const url = window.URL.createObjectURL(new Blob(binaryData, {type: "application/zip"})) // const url = window.URL.createObjectURL(res) var a = document.createElement('a') document.body.appendChild(a) a.href = url a.download = '院校資訊.xls' a.click() window.URL.revokeObjectURL(url) this.$message.success('院校資訊匯出成功');