Blob 下载

£可爱£侵袭症+ 提交于 2019-12-10 14:05:04
在这里插入代码片// 点击下载
    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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!