Pat*_*cow 4 javascript storage google-chrome-extension google-chrome-storage
我有一个存储在chrome存储中的对象,如下所示:
{
"planA":
{
123: {key: 'some key'}
124: {key: 'some other key'}
},
"planB":
{
223: {key: 'some key'}
234: {key: 'some other key'}
}
}
Run Code Online (Sandbox Code Playgroud)
我想做点什么 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)
蚂蚁想法?
您不能在单个API调用中执行此操作.API仅允许访问顶级键:您可以获取或设置planA整体.
因此,您需要编写自己的get/set函数,检索所需的顶级键,根据需要修改对象,然后将其保存.