ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# JS写文件 ~~~ <script> function saveShareContent(content, file) { let link = document.createElement('a') let blob = new Blob([content]) link.download = file link.href = URL.createObjectURL(blob) document.body.appendChild(link) link.click() document.body.removeChild(link) } for (let i = 0; i < 3; i++) { saveShareContent(i, 'log' + i + '.txt'); } </script> ~~~ # indexedDB数据库 ~~~ <script> const request = indexedDB.open('myDatabase', 3); request.addEventListener('success', e => { const db = e.target.result; const tx = db.transaction('User','readwrite'); const store = tx.objectStore('User'); const reqAdd = store.add({'userId': 1, 'name': '123'}); reqAdd.addEventListener('success', e => { console.log('保存成功') }) }); </script> ~~~