//以下是 浏览器下a标签支持download属性的时候 即"download" in document.createElement("a") 成立
//下面的contant是要保存到本地的信息属于字符串格式,如果是数组或者对象格式,请先调用JSON.stringify对数据进行字符串化处理let blob = new Blob([contant], {type: "text/plain;charset=utf-8"})
const elink = document.createElement("a")
elink.download = 'save.json'
elink.style.display = "none"
elink.href = URL.createObjectURL(blob)
document.body.appendChild(elink)
URL.revokeObjectURL(elink.href)
// IE10+下载
//下面的contant是要保存到本地的信息属于字符串格式,如果是数组或者对象格式,请先调用JSON.stringify对数据进行字符串化处理
let blob = new Blob([contant], {type: "text/plain;charset=utf-8"})
let fileName= 'save.json'
navigator.msSaveBlob(blob, fileName)