0

基本上,有一个存储的原语我想设置为 jQuery UI Tab 设置的值:

$("#tabs").tabs({
    active: chrome.storage.local.get("idx", function(obj){ 
                console.log(obj["idx"])}); // returns primitive integer I want. 
            }), ...  
}); 

标准的 chrome-storage-get 协议非常复杂,我不确定如何简单地将对象属性值本身设置为值active:而不是对象。

active: 3 // chrome.storage.local.get("idx")

有什么办法可以做到这一点?

4

1 回答 1

2

chrome.storage是异步的,所以你的代码看起来更像这样:

chrome.storage.local.get("idx", function(obj) {
  $("#tabs").tabs({
    active: obj.idx  
  });
});
于 2015-03-03T15:09:48.600 回答