当我尝试从我的 firefox 扩展打开 indexeddb 时出现以下错误
[异常...“非法值”nsresult:“0x80070057(NS_ERROR_ILLEGAL_VALUE)”位置:“JS frame::chrome://extension/abc.html::openDb::line 213”数据:无]
const DB_NAME = 'dbName';
const DB_VERSION = 1;
const DB_STORE_NAME = 'dbStore';
var db;
function openDb() {
try{
var req = indexedDB.open(DB_NAME, DB_VERSION);
req.onsuccess = function (evt) {
db = this.result;
};
req.onerror = function (evt) {
console.error("openDb:", evt.target.errorCode);
};
req.onblocked = function(evt) {
// If some other tab is loaded with the database, then it needs to be closed
// before we can proceed.
console.log("Please close all other tabs with this site open!");
alert("Please close all other tabs with this site open!");
};
}
catch(err){
alert(err);
}
}
它进入带有上述引用错误的 catch 部分。
提前致谢。
最佳答案
下面应该给出一个有效的 indexedDB
Components.utils.importGlobalProperties(["indexedDB"]);
我只测试了 open
是否返回有效的 IDBDatabase
对象。请确认数据存储和检索。
(这只是一个解决方法,indexedDB
访问器方法有问题)
编辑:Chrome 对话框有一个有效的 indexedDB
关于javascript - 无法在 Firefox 中打开 IndexedDB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22956440/