4***@qq.com
4***@qq.com
  • 发布:2022-06-27 17:55
  • 更新:2022-11-01 13:36
  • 阅读:433

【报Bug】HBuilderX中内置浏览器插件indexedDb无法保存

分类:HBuilderX

产品分类: HbuilderX

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Windows 10 19044.1766

HBuilderX版本号: 3.4.15

示例代码:

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 = () => {
};

操作步骤:

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 = () => {
};

预期结果:

保存成功

实际结果:

返回保存成功,但是实际没有成功

bug描述:

indexedDb的 add()方法,返回保存成功,但是Application中没有保存的内容

2022-06-27 17:55 负责人:无 分享
已邀请:
小刀雨斑

小刀雨斑

解决了吗?在内置浏览器内看不到数据,但是直接用chrome是正常的,但是用chrome调试起来不太方便

该问题目前已经被锁定, 无法添加新回复