如何清除 chrome.storage.sync 以测试我的扩展程序?
How do I clear chrome.storage.sync for testing my extension?
我正在制作一个小逻辑游戏作为 chrome 扩展,以添加我想使用的高分 chrome.storage.sync。我只想创建一个不存在的变量(第一次有人打开扩展程序)。为了测试我写的东西是否有效,我必须自己清除所有数据,我该怎么做? (文档讲的是高级开发人员,我不是其中之一,所以我不明白)
https://developer.chrome.com/docs/extensions/reference/storage/
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)
})
我正在制作一个小逻辑游戏作为 chrome 扩展,以添加我想使用的高分 chrome.storage.sync。我只想创建一个不存在的变量(第一次有人打开扩展程序)。为了测试我写的东西是否有效,我必须自己清除所有数据,我该怎么做? (文档讲的是高级开发人员,我不是其中之一,所以我不明白)
https://developer.chrome.com/docs/extensions/reference/storage/
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)
})