Skip to content

Instantly share code, notes, and snippets.

@onsummer
Last active May 24, 2021 01:28
Show Gist options
  • Save onsummer/098f967b88540552cf8428c961024b59 to your computer and use it in GitHub Desktop.
Save onsummer/098f967b88540552cf8428c961024b59 to your computer and use it in GitHub Desktop.
localForage-demo
import localForage from 'localforage'
// 创建仓库对象,并创建名为 “test” 的 indexeddb 以及 名为 “testidb” 的表
const store = localForage.createInstance({
driver: localForage.INDEXEDDB,
name: "test",
storeName: "testidb"
})
// 设置 key-value
store.setItem("t1", new Float32Array([113.24, 44.55, 12.512]))
// 5 秒后删除 “test” 数据库的 “testidb” 这个表
setTimeout(() => {
localForage.dropInstance({
name: "test",
storeName: "testidb"
})
}, 5000)
@onsummer
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment