当前位置:网站首页>浏览器端保存数据到本地文件
浏览器端保存数据到本地文件
2022-07-01 05:56:00 【乘风xs】
function localSave(data:any, filename: string){
if(!data) {
console.error('Console.save: No data')
return;
}
if(!filename) filename = 'console.json'
if(typeof data === "object"){
data = JSON.stringify(data, undefined, 4)
}
var blob = new Blob([data], {type: 'text/json'}),
e = document.createEvent('MouseEvents'),
a = document.createElement('a')
a.download = filename
a.href = window.URL.createObjectURL(blob)
a.dataset.downloadurl = ['text/json', a.download, a.href].join(':')
e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
a.dispatchEvent(e)
}边栏推荐
- Codeforces Round #803 (Div. 2)vp
- LeetCode 最大矩形,最大正方形系列 84. 85. 221. 1277. 1725. (单调栈,动态规划)
- 穿越派·派盘 + 思源笔记 = 私人笔记本
- Code shoe set - mt3149 · and - the data is not very strong. Violent pruning can deceive AC
- Preliminary level of C language -- selected good questions on niuke.com
- 3D打印机穿线:5种简单的解决方案
- Primary application case of Excel DuPont analyzer
- In win10 and win11, the scroll direction of Elan touch panel is reversed, and "double finger click to open the right-click menu" and "double finger scroll" are started“
- PLA不粘贴在床上:6个简单的解决方案
- Dear pie users, I want to confess to you!
猜你喜欢

Geoffrey Hinton:我的五十年深度学习生涯与研究心法

OpenGL es: (3) EGL, basic steps of EGL drawing, eglsurface, anativewindow

C语言初阶——牛客网精选好题

excel動態圖錶

穿越派与贸大合作,为大学生增添效率

π disk, turning your computer into a personal private cloud

Geoffrey Hinton: my 50 years of in-depth study and Research on mental skills

Preliminary level of C language -- selected good questions on niuke.com

【文件系统】如何在ubi之上运行squashfs

C语言初阶——实现扫雷游戏
随机推荐
Ucosiii --- engineering transplantation
Xuanyi maintenance manual
C语言初阶——实现扫雷游戏
Orcle创建用户+角色
Oracle 序列+触发器
Multi label lsml for essay learning records
SystemVerilog学习-06-类的封装
Don't put your notes and videos everywhere!
输入一个表达式(用字符串表示),求这个表达式的值。
Oracle create user + Role
关于一道01背包问题的·拓展题的思考
El tooltip in the table realizes line breaking display
scope 数据导出mat
It's not that you have a bad mind, but that you haven't found the right tool
Thoughts on a "01 knapsack problem" expansion problem
Advanced cross platform application development (III): online resource upgrade / hot update with uni app
How to add a gourd pie plate
HCM 初学 ( 二 ) - 信息类型
这才是大学生必备软件 | 知识管理
Brief description of activation function