我正在尝试使用用户单击的(用户的)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?
})
我正在尝试使用用户单击的(用户的)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?
})
您可以尝试以下方法:
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.
});