5

我有一个存储在 chrome 存储中的对象,如下所示:

{
    "planA": 
    {
        123: {key: 'some key'}
        124: {key: 'some other key'}
    },
    "planB": 
    {
        223: {key: 'some key'}
        234: {key: 'some other key'}
    }
}

我想做类似的事情chrome.storage.sync.remove([{"planA": "123"}]);

但这似乎不起作用Error in response to storage.get: Error: Invalid value for argument 1. Value does not match any valid type choices.

文档 StorageArea.remove(string or array of string keys, function callback)

蚂蚁的想法?

4

1 回答 1

6

您不能在单个 API 调用中做到这一点。API 仅提供对顶级密钥的访问权限:您可以planA整体获取或设置。

因此,您需要编写自己的 get/set 函数,检索所需的顶级键,根据需要修改对象,然后将其保存回来。

于 2015-03-09T22:35:17.323 回答