如何在 chrome 中使用 chrome.storage.local.get 设置变量
How to set the variable with chrome.storage.local.get in chrome
var curline;
chrome.storage.local.get("value",function(item)
{
window.curline=item["value"];
});
alert(curline);
我想将 curline
设置为 item["value"]
,此代码在 inject.js
中,谢谢。
chrome.storage API is asynchronous。回调稍后执行,在你提醒之后。
这意味着您必须在您传递的回调中提醒结果:
var curline;
chrome.storage.local.get("value",function(item)
{
window.curline=item["value"];
alert(curline);
// here you may use curline, or pass it as argument to other functions
});
var curline;
chrome.storage.local.get("value",function(item)
{
window.curline=item["value"];
});
alert(curline);
我想将 curline
设置为 item["value"]
,此代码在 inject.js
中,谢谢。
chrome.storage API is asynchronous。回调稍后执行,在你提醒之后。
这意味着您必须在您传递的回调中提醒结果:
var curline;
chrome.storage.local.get("value",function(item)
{
window.curline=item["value"];
alert(curline);
// here you may use curline, or pass it as argument to other functions
});