相关疑难解决方法(0)

Indexeddb:onsuccess和oncomplete之间的差异?

当IndexedDB事务完成或成功时,我使用两个不同的事件来响应回调:

假设... db:IDBDatabase对象,tr:IDBTransaction对象,os:IDBObjectStore对象

tr = db.transaction(os_name,'readwrite');
os = tr.objectStore();
Run Code Online (Sandbox Code Playgroud)

情况1 :

r = os.openCursor();
r.onsuccess = function(){
    if(r.result){
        callback_for_result_fetched();
        r.result.continue;
    }else callback_for_transaction_finish();
}
Run Code Online (Sandbox Code Playgroud)

案例2:

tr.oncomplete = callback_for_transaction_finish();
Run Code Online (Sandbox Code Playgroud)

如果它们两者的工作方式相似则是浪费.所以你能告诉我,他们之间有什么区别吗?

database indexeddb

5
推荐指数
2
解决办法
4420
查看次数

标签 统计

database ×1

indexeddb ×1