当前第2页 返回上一页
1 2 3 4 5 6 7 8 9 | request.addEventListener( 'success' , function (event){
const db = event.target.result;
db.transaction(objectStoreName, wa);
const store = transaction.objectStore(objectStoreName);
}, false);
|
数据库的增删改查:
1 2 3 4 5 6 7 8 9 10 11 12 13 | store.add(obj);
store.put(obj);
store. delete (value);
store.clear();
const g = store.get(value);
g.addEventListener( 'success' , function (event){
}, false);
|
按索引查找数据
1 2 3 4 5 6 7 8 9 | const index = store.index(indexName);
const cursor = index.openCursor(range);
cursor.addEventListener( 'success' , function (event){
const result = event.target.result;
if (result){
result.value
result. continue ();
}
}, false);
|
按索引的范围查找数据
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | const index = store.index(indexName);
const cursor = index.openCursor(range);
range = IDBKeyRange.lowerBound(value, true)
range = IDBKeyRange.lowerBound(value, false)
range = IDBKeyRange.upperBound(value, isOpen)
IDBKeyRange.bound(value1, value2, isOpen1, isOpen2)
|
最后,自己封装了一个indexedDB的库,可以参考一下:duan602728596/IndexedDB
以上就是HTML5 IndexedDB本地储存的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
h5如何使用约束验证api
h5的filereader怎样分布读取文件
html中序列化标签的简单介绍(代码实例)
html5容易被忽略的小知识
html5 web 存储详解
服务端主动发送数据回客户端在h5里的实现步奏
wps h5是什么软件
字符编码是什么?html5如何设置字符编码?
如何利用html5 canvas旋转图片?(实例演示)
想学好html5看什么书好
更多相关阅读请进入《indexeddb》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » HTML5 IndexedDB本地储存