0

我正在尝试使用用户单击的(用户的)ID 创建一个数组。功能是:

$('button').click(function(){
var value = $('this').parents('.username').attr('id')
// How to create array in the chrome storage?

// How can I push the value to an array and create a permanent one?
})
4

1 回答 1

1

您可以尝试以下方法:

chrome.storage.local.get("myArray", function(dataStored) {  //load your saved array, if it exists
  var workingArray = dataStored.myArray || [];  //if it doesn't exist, create an empty one
  workingArray.push(value);  //add the value just obtained
  chrome.storage.local.set({myArray:workingArray});  //save the array.
});
于 2016-07-03T19:31:46.670 回答