存储:
var arr = [1,2,3];
var str = JSON.stringify(arr);
localStorage.setItem("items", str);
读取:
var items = localStorage.getItem("items");
var arr = JSON.parse(items);
存储:
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存储和读取数组
本文链接:https://www.haomeiwen.com/subject/ltkbzhtx.html
网友评论