IndexedDB,open数据库,一直不成功。 error.message:The operation failed for reasons unrelated to the database...

使用火狐开发,用indexedDB,打开数据库的时候,某台电脑一直进onerror,查看error的message,却提示:

The operation failed for reasons unrelated to the database itself and not covered by any other error code.(操作失败的原因和数据库本身没有关系,也不包含其他错误的代码)。

完全没有用的错误信息..  一番搜索也没找到解决办法。修改数据库名、版本号、清理缓存各种方法无效...

最后发现,是使用的目录太深:

把目录改到Descktop后,能正常打开数据库。 (供参考)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
`indexedDB.open()` 是 HTML5 中用于打开 IndexedDB 数据库的方法。它的语法如下: ``` const request = window.indexedDB.open(name, version); ``` 其中,`name` 是要打开的数据库的名称,`version` 是数据库的版本号。这个方法会返回一个 IDBRequest 对象,表示打开数据库的请求。 `indexedDB.open()` 方法执行时会检查指定名称的数据库是否存在。如果存在,它会检查数据库的版本号。如果数据库的版本号低于指定的版本号,它会触发 `upgradeneeded` 事件,允许你更新数据库的结构。如果数据库的版本号等于或高于指定的版本号,它会触发 `success` 事件,表示成功打开了数据库连接。 以下是一些常见的 `indexedDB.open()` 方法的用法: 1. 打开一个新的数据库连接: ``` const request = window.indexedDB.open('myDatabase', 1); request.onerror = function(event) { console.log('Database error: ' + event.target.errorCode); }; request.onsuccess = function(event) { const db = event.target.result; // 执行操作... }; ``` 2. 打开一个已经存在的数据库连接: ``` const request = window.indexedDB.open('myDatabase', 1); request.onerror = function(event) { console.log('Database error: ' + event.target.errorCode); }; request.onsuccess = function(event) { const db = event.target.result; // 执行操作... }; request.onupgradeneeded = function(event) { // 更新数据库结构... }; ``` 注意,如果你只希望打开或创建一个新的数据库连接,而不需要更新数据库结构,你可以省略 `onupgradeneeded` 事件处理程序。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值