Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/429.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 开发chrome扩展时如何清除'chrome.storage.local'缓存?_Javascript_Google Chrome_Caching_Google Chrome Extension - Fatal编程技术网

Javascript 开发chrome扩展时如何清除'chrome.storage.local'缓存?

Javascript 开发chrome扩展时如何清除'chrome.storage.local'缓存?,javascript,google-chrome,caching,google-chrome-extension,Javascript,Google Chrome,Caching,Google Chrome Extension,我已经为我的库编写了一个Chrome扩展。它使用chrome.storage.local来缓存东西 有人知道如何删除缓存以进行测试吗?我不能再进行测试了,因为所有的数据都在缓存中。我想扔掉它,确保它被正确地重新填充,等等。我该怎么做 我尝试“刷新”扩展,但没有任何效果。删除和添加扩展也不会清除缓存。使用() 要检查状态,请使用回调(可选): chrome.storage.local.clear(函数(){ var error=chrome.runtime.lastError; 如果(错误){ 控

我已经为我的库编写了一个Chrome扩展。它使用
chrome.storage.local
来缓存东西

有人知道如何删除缓存以进行测试吗?我不能再进行测试了,因为所有的数据都在缓存中。我想扔掉它,确保它被正确地重新填充,等等。我该怎么做

我尝试“刷新”扩展,但没有任何效果。删除和添加扩展也不会清除缓存。

使用()

要检查状态,请使用回调(可选):

chrome.storage.local.clear(函数(){
var error=chrome.runtime.lastError;
如果(错误){
控制台错误(error);
}
});

如果要从存储中删除任何特定对象或特定对象列表,也可以使用chrome.storage.local.remove()方法

chrome.storage.local.remove(["Key1","key2"],function(){
 var error = chrome.runtime.lastError;
    if (error) {
        console.error(error);
    }
})
看看这个

chrome.storage.local.remove(keyName,function() {
 // Your code
 // This is an asyn function
});

检查完整详细信息

删除扩展也将删除chrome.storage.local。您可能有代码在每次安装时都会填充它,所以您会看到相同的数据,但当删除扩展时,chrome将删除其存储tooYep,删除扩展即可。在开发者模式下,在清除数据之前,Fking chrome应该给开发者一些警告。