尝试使用本地存储在我的 Chrome 扩展程序中设置和获取值。不知道我做了什么,但它不再起作用了。¡
在 list 中我有:
"permissions": [
"tabs", "http://*/*", "https://*/*", "storage"
],
这是完整的js,它设置一个值,然后尝试读取它:
chrome.storage.local.set({'userid': "foo"}, function (result) {
chrome.storage.local.get('userid', function (result) {
alert(userid.result);
});
});
警报显示“未定义”,而不是预期的“foo”。
当我转到 list 中为“content_scripts”指定的某个页面时,会执行 js。
最佳答案
呵呵,我明白了。应该是:
alert(result.userid);
(反转用户 ID 和结果)
关于google-chrome-extension - Chrome扩展存储: set/get value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16303268/