我正在制作一个小小的逻辑游戏,作为一个铬的扩展,以增加一个高分,我想使用chrome.storage.sync。我只想创建一个变量,如果它不存在(第一次有人打开扩展)。为了测试我所写的作品是否有效,我必须为自己清除所有的数据,我怎么能做到呢?(这些文档说的是高级开发人员,我不是其中之一,所以我不明白)
https://developer.chrome.com/docs/extensions/reference/storage/
发布于 2021-09-09 07:47:04
chrome.storage.local.clear()
这将从存储中移除所有项目。
您还可以删除一些键,而不是所有的项,
chrome.storage.local.get((data) => {
// here you get all data and you can decide which keys to delete,
// in this case im deleting all keys explicitly
chrome.storage.local.remove(Object.keys(data), resolve)
})
https://stackoverflow.com/questions/69114081
复制相似问题