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 に答える