localStorage存储和读取数组

存储:

var arr = [1,2,3];
var str = JSON.stringify(arr);
localStorage.setItem("items", str);

读取:

var items = localStorage.getItem("items");
var arr = JSON.parse(items);

你可能感兴趣的:(localStorage存储和读取数组)