繁体   English   中英

IndexedDB:无法在“IDBDatabase”上执行“事务”:未找到指定的 object 商店之一

[英]IndexedDB: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found

我只是为我的反应 PWA 启动了一个 indexedDB。 我得到这个错误。

Uncaught DOMException: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found. at request.onsuccess

行是: const transaction = db.transaction("storeName", "readwrite");

和我做的功能:

  const handleSubmit = (event) => {
    event.preventDefault();

    const request = window.indexedDB.open("NewApp", 1);

    request.onsuccess = () => {
      if (nameArea && enterDate) {
        const db = request.result;
        const transaction = db.transaction(["apps"], "readwrite");
        const store = transaction.objectStore("apps");
        store.put({ nameArea, enterDate: Date.now() });

        const query = store.get(1);

        query.onsuccess = function () {
          console.log("next info", query.result);
        };

        transaction.oncomplete = function () {
          /db.close();
        };
      };

      request.onerror = function (event) {
        console.error("An error occurred with IndexedDB");
        console.error(event);
      };
    }
  };

这个问题只出现在新打开的浏览器中,当我调试它时,记录正在添加但不仅仅是空字符串。

我只是更改了版本并重新创建了数据库。 所以现在它正在工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM