Created
September 20, 2018 04:13
-
-
Save LeoHeo/23298c2c44c45d87691970321aae3c5c to your computer and use it in GitHub Desktop.
axios로 excel 다운로드 할려고 할때 location.href가 아닌 progress bar 뜰 수 있게 하는 방식
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
axios.get(url, { | |
responseType: 'arraybuffer' | |
}).then(function (response) { | |
var blob = new Blob([response.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }); | |
var blobURL = window.URL.createObjectURL(blob); | |
var tempLink = document.createElement('a'); | |
tempLink.style.display = 'none'; | |
tempLink.href = blobURL; | |
tempLink.setAttribute('download', 'test.xlsx'); | |
document.body.appendChild(tempLink); | |
tempLink.click(); | |
document.body.removeChild(tempLink); | |
window.URL.revokeObjectURL(blobURL); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment