小编Yus*_*pek的帖子

IndexedDB 错误:无法克隆 IDBObjectStore 符号

我有一个类,其中某些属性不应存储到 indexedDB 存储中。当我克隆对象并随后删除属性时,它会起作用,但是我不太喜欢该解决方案。我想知道是否有一个解决方案,我们只需将属性设置为私有,因此在写入 indexedDB 存储时不应包含该属性。

我尝试了以下操作:我在类中使用了符号作为属性,并通过 get/set 修改了属性,但是当我尝试将对象存储到 indexedDB 存储时,出现以下错误:IndexedDB 错误:IDBObjectStore 符号无法被克隆

这是一个示例代码:

var request = indexedDB.open('test', 2);

request.onerror = function(event) {
    // Handle errors.
};
request.onupgradeneeded = function(event) {
    var db = event.target.result;

    // Create an objectStore to hold information about our customers. We're
    // going to use "ssn" as our key path because it's guaranteed to be
    // unique.
    var objectStore = db.createObjectStore("customers", {
        keyPath: 'id'
    });

    var mystring = "Hello World"
    
    var myblob = new Blob([mystring], …
Run Code Online (Sandbox Code Playgroud)

javascript indexeddb

6
推荐指数
1
解决办法
2178
查看次数

标签 统计

indexeddb ×1

javascript ×1