当前位置:网站首页>浏览器端保存数据到本地文件
浏览器端保存数据到本地文件
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)
}边栏推荐
- 从诺奖知“边缘计算”的未来!
- TiDB单机模拟部署生产环境集群(闭坑实践,亲测有效)
- Advanced cross platform application development (III): online resource upgrade / hot update with uni app
- PLA不粘贴在床上:6个简单的解决方案
- Some errors encountered in MySQL data migration
- 输入一个表达式(用字符串表示),求这个表达式的值。
- 数据库er图组成要素
- Why use huluer pie disk instead of U disk?
- El tooltip in the table realizes line breaking display
- OpenGL ES: (2) OpenGL ES 与 EGL、GLSL的关系
猜你喜欢

Continue to learn MySQL

论文学习记录随笔 多标签之LSML

Ucosiii --- engineering transplantation

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

解决麒麟V10上传文件乱码问题

SystemVerilog学习-08-随机约束和线程控制

linux 关闭redis 进程 systemd+

论文学习记录随笔 多标签之LIFT

Qt编写自定义控件-自绘电池

What if the data in the cloud disk is harmonious?
随机推荐
OpenGL es: (3) EGL, basic steps of EGL drawing, eglsurface, anativewindow
运行时候的导包搜索路径虽然pycharm中标红但不影响程序的执行
论文学习记录随笔 多标签之LIFT
从诺奖知“边缘计算”的未来!
Smartinstantiationawarebeanpostprocessor of the extension point series determines which construction method to execute - Chapter 432
Advanced cross platform application development (III): online resource upgrade / hot update with uni app
This is the necessary software for college students 𞓜 knowledge management
PLA不粘贴在床上:6个简单的解决方案
Scope data export mat
Small guide for rapid completion of mechanical arm (VI): stepping motor driver
为了保护自己的数据,他奋斗了一天一夜
Bat operation FTP upload and download command
【笔记】电商订单数据分析实战
Flink实战--多流合并
Debug details under pycharm
Oracle 序列+触发器
Geoffrey Hinton: my 50 years of in-depth study and Research on mental skills
SystemVerilog学习-10-验证量化和覆盖率
Primary application case of Excel DuPont analyzer
健康照明中应用的LED照明灯