let request = indexedDB.open('msgDB', 1);
request.onerror = e => console.log(e.currentTarget.error.message);
request.onsuccess = e => this.db = e.target.result;
request.onupgradeneeded = e => {
let thisDB = e.target.result;
if (!thisDB.objectStoreNames.contains("totmsg")) {
// 创建数据表并设置id为自增主键
let objStore = thisDB.createObjectStore("totmsg", {keyPath: "id",autoIncrement: true });
}
}
this.transaction = this.db.transaction("totmsg", 'readwrite');
this.transaction.oncomplete = () => console.log("transaction complete");
this.transaction.onerror = e => console.dir(e);
let objectStore = this.transaction.objectStore("totmsg");
let request = objectStore.add({aaa:"sbvgdfdbh"});
request.onsuccess = () => {
};
request.onerror = () => {
};
1 个回复
小刀雨斑
解决了吗?在内置浏览器内看不到数据,但是直接用chrome是正常的,但是用chrome调试起来不太方便