无法理解为什么会发生这种情况:
var request=window.indexedDB.open("known"); //async IDB request
request.onsuccess=function(){db=event.target.result;
alert("database created"+db); //it works fine database created
var store=db.createObjectStore("friends",{pathKey:"name"})
//error **"Uncaught InvalidStateError: An operation was called on an object on which it is not allowed or at a time when it is not allowed."** as on console box
}
当数据库已被指定为“已知”数据库时,为什么会弹出错误?
2条答案
按热度按时间w8biq8rn1#
当您在版本变更交易中时,您只能呼叫createObjectStore,这大致Map到需要升级的事件行程常式。而且,它是“keyPath”,而不是“pathKey”。请尝试
规范中有一些很好的例子。
cygmwpex2#
看起来您好像忘记命名回调的参数了?请尝试:
这样,就定义了“事件”。