使用chrome.storage.get获取变量
Using chrome.storage.get to get a variable
我正在做一个小的Chrome扩展,我已经成功地使用选项页面来使用Chrome.storage.sync.set来设置变量pws。但是,在弹出页面上,我无法成功检索变量并在字符串中使用它。这是它的代码:
weather.open("GET", "http://api.wunderground.com/api/"+WU_API_KEY+"/conditions/q/CA/pws:"+pws+".json", true);
weather.send()
})
如何从chrome.sync.storage.get中获取pws作为变量?
我试过类似的东西
chrome.storage.sync.get(pws, function(result){
var pws = result.pws
console.debug('result:',pws);
});
但无济于事。
如果使用"pws"
作为存储pws
的密钥,则可以:
chrome.storage.sync.get("pws", function(result) {
var pws = result.pws;
console.log("result:", pws);
});
相关文章:
- Javascript:无法获取变量中的单选按钮值
- 活动选项卡's源代码-获取变量s值
- 使用nodejs从url中获取变量
- Handlebars帮助程序未获取变量的值
- 通过Ajax获取变量
- for 循环和 if 语句,获取变量并存储它
- 从javascript表达式(Rhino)中获取变量
- 如何从 Chrome 扩展程序中的内容脚本中获取变量
- 从对象实例中获取变量名称
- 如何通过 .get() 从文件中获取变量
- 使用chrome.storage.get获取变量
- Rails/JS-在不刷新页面的情况下获取变量
- Jquery:如何获取变量的局部外部函数
- 从外部js文件获取变量
- 如何获取变量's设置元素时的文字值's onclick处理程序
- 从查询字符串中获取变量,将其与Javascript中的数组匹配
- 如何在另一个php文件中从ajax获取变量
- 通过Ajaxrequest.open从Javascript获取变量到PHP文件
- Jade:在Bootstrap Modal中获取变量
- 使用Chrome扩展从以前的选项卡中获取变量