文件blob下载
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
const blob = new Blob([res.data], { | |
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' | |
// 文件格式 | |
}) | |
if ('download' in document.createElement('a')) { // 非IE下载 | |
const elink = document.createElement('a') | |
elink.download = 'markone' | |
elink.style.display = 'none' | |
elink.href = URL.createObjectURL(blob) | |
document.body.appendChild(elink) | |
elink.click() | |
URL.revokeObjectURL(elink.href) // 释放URL 对象 | |
document.body.removeChild(elink) | |
} else { // IE10+下载 | |
navigator.msSaveBlob(blob, 'markone') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment