【问题标题】:indexedDB Creating a database and adding content Failed to execute 'transaction' on 'IDBDatabase'indexedDB 创建数据库并添加内容未能在“IDBDatabase”上执行“事务”
【发布时间】:2016-08-25 14:59:17
【问题描述】:

这是我第一次使用 indexDB,我已经创建了一个数据库,现在正在尝试向其中添加内容。但我收到以下错误。

未捕获的 NotFoundError:无法在“IDBDatabase”上执行“事务”:未找到指定的对象存储之一。

我将我的代码上传到 jsfiddle 只是因为它更容易向您展示它正在运行。请问有什么建议吗?

https://jsfiddle.net/8kj43kyn/

// Creating an indexDB - Used to store users information.  
window.indexedDB = window.indexedDB || window.mozIndexedDB || 
window.webkitIndexedDB || window.msIndexedDB;

【问题讨论】:

    标签: javascript local indexeddb persistent-object-store


    【解决方案1】:

    应该这样

    var transaction = db.transaction( ["books", 'readwrite']);
    

    成为

    var transaction = db.transaction(["books"], 'readwrite');
    

    【讨论】:

    • 请注意,一旦您进行了此更改并为了重新测试,您需要在浏览器上打开一个新选项卡。仅仅刷新是不够的。不知道为什么
    猜你喜欢
    • 2021-01-16
    • 2017-07-11
    • 2021-05-15
    • 2016-02-16
    • 1970-01-01
    • 2021-02-17
    • 1970-01-01
    • 1970-01-01
    • 2021-06-20
    相关资源
    最近更新 更多