gpt4 book ai didi

javascript - 无效状态错误: DOM IDBDatabase Exception 11

转载 作者:行者123 更新时间:2023-11-28 11:37:12 25 4
gpt4 key购买 nike

有人可以告诉我我哪里出了问题吗?

window.indexedDB = window.indexedDB || window.webkitIndexedDB ||
window.mozIndexedDB;

if ('webkitIndexedDB' in window) {
window.IDBTransaction = window.webkitIDBTransaction;
window.IDBKeyRange = window.webkitIDBKeyRange;
}

var VULY_DB = {};
VULY_DB = {};
VULY_DB.db = null;

VULY_DB.onerror = function(e) {
console.log(e);
};

VULY_DB.open = function() {
var request = indexedDB.open(salt);


request.onerror = request.onsuccess = function(e) { VULY_DB.onerror(request.error); };
request.onsuccess = function(e) {
VULY_DB.db = e.target.result;
var db = VULY_DB.db;

var store = db.createObjectStore("revisions", {keyPath: "id"});
};
};

VULY_DB.open();

谢谢!

最佳答案

您需要在 onupgradeneeded 方法中创建 objectStore,而不是 onsuccess。

请参阅“构建数据库”下的 MDN 示例:

https://developer.mozilla.org/en-US/docs/IndexedDB/Using_IndexedDB

关于javascript - 无效状态错误: DOM IDBDatabase Exception 11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16765146/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com