Created
October 10, 2019 03:14
-
-
Save renzhezhilu/60ec5498bc516cf719eae4ff5f791ed1 to your computer and use it in GitHub Desktop.
[下载文件/bolb转文本文件] #数据转换
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
//下载文件 | |
// funDownload(JSON.stringify(xxxx),'xxx.json') | |
function funDownload(content, filename) { | |
let eleLink = document.createElement('a'); | |
eleLink.download = filename; | |
eleLink.style.display = 'none'; | |
// 字符内容转变成blob地址 | |
let blob = new Blob([content]); | |
eleLink.href = URL.createObjectURL(blob); | |
// 触发点击 | |
document.body.appendChild(eleLink); | |
eleLink.click(); | |
// 然后移除 | |
document.body.removeChild(eleLink); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment