在chrome.storage中显示所有内容 [英] Show everything in chrome.storage

查看:102
本文介绍了在chrome.storage中显示所有内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 console.log(chrome.storage),但是它没有返回任何有用的信息.我已经使用 chrome.storage.sync.set 在扩展程序中设置了一些值,并希望看到它们.

I tried to use console.log(chrome.storage) but it doesn't return anything helpful. I have already set some values in my extensions using chrome.storage.sync.set and want to see them.

我可以键入 console.log(localStorage)并查看其中的所有内容.chrome.storage怎么做?

I can type console.log(localStorage) and see everything in it. How to do such with chrome.storage?

推荐答案

您必须等待 chrome.storage.sync.set()操作完成.做到这一点的方法之一就是回调函数.您通过 chrome.storage.sync.set()传递的值可在回调中使用:

You have to wait for the completion of chrome.storage.sync.set() action. One of the ways to do it is the callback function. The value you pass with chrome.storage.sync.set() is available within callback:

chrome.storage.sync.set({'key1': 123}, function() {
  chrome.storage.sync.get("key1", function(data) {
    console.log("data", data);
  });
});

这篇关于在chrome.storage中显示所有内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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