Chrome扩展程序:使用chrome.storage.sync.get获取空白对象? [英] Chrome extension : got blank object using chrome.storage.sync.get?

查看:1205
本文介绍了Chrome扩展程序:使用chrome.storage.sync.get获取空白对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  chrome.storage.sync.get(accounts,function(obj){
console.log(obj);
});

不知道有什么问题我有帐户作为键和一些值,但是我使用上面的代码得到空白对象。



正如你所看到的,我确实在localstorage中有一些东西:


$ b

但为什么它是空白对象?





我没有权限问题,但它为什么是空白对象?

解决方案 localStorage 存储和 chrome.storage



开发工具只显示 localStorage ;有开发工具的第三方扩展,例如显示 chrome.storage 存储区域资源管理器



localStorage chrome.storage.local chrome.storage.sync 全都不同。


chrome.storage.sync.get("accounts", function (obj) {
    console.log(obj);
});

not sure what's wrong i have accounts as key and some value, but I got blank object using above code.

As you can see I did have something in my localstorage :

But why is it a blank object?

I have no permission issue, but why is it a blank object?

解决方案

You're confusing localStorage storage and chrome.storage.

Dev Tools only show localStorage; there are third-party extensions to Dev Tools that show the chrome.storage, e.g. Storage Area Explorer

localStorage, chrome.storage.local and chrome.storage.sync are all different.

这篇关于Chrome扩展程序:使用chrome.storage.sync.get获取空白对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆