在这里插入代码片// 点击下载
download = () => {
const { table_Data } = this.props
const blob = new Blob([JSON.stringify(table_Data)], {type: 'text/plain'}) // {type : 'application/json'}
let a = document.createElement('a')
let url = URL.createObjectURL(blob)
a.href = url
a.download = '表格数据'
a.click()
setTimeout(() => {
//删除创建的URL
window.URL.revokeObjectURL(url)
}, 0)
}
// 相关链接
// 【官方链接】 https://developer.mozilla.org/zh-CN/docs/Web/API/Blob
// 【HTML5】Blob对象 https://www.jianshu.com/p/e45522c7f6c9
// URL.createObjectURL和URL.revokeObjectURL https://www.jianshu.com/p/2fb76868248b
来源:CSDN
作者:辅助辅助助辅
链接:https://blog.csdn.net/qq_40924034/article/details/103473748