indexedDB中IDBDatabase对象已生成但不能调用createObjectStore方法创建命名空间,提示Uncaught TypeError: Cannot read property 'createObjectStore' of undefined。
下面是代码
var request = indexedDB.open("jusing"),
db;
user = {
username: "jusing",
age: 18,
gender: "male",
handsome: true
}
request.onsuccess = function() {
db = event.target.result;
}
var store = db.createObjectStore("users", {keyPath: "username"});
store.add(user);
慕村225694
相关分类