首页 > 技术文章 > 本次存储存数组对象

shaozhu520 2019-01-18 10:33 原文

var arrLi = [{"search_content":"火锅"},{"search_content":"火锅1"},{"search_content":"火锅2"}];//定义

localStorage.setItem("searchLI",JSON.stringify(arrLi));

 

 

获取

var arrLi1 = JSON.parse(localStorage.getItem("searchLI"));

 

累加:

arrLi1.push({"search_content":"火锅"})
;
修改:

localStorage.setItem("searchLI",JSON.stringify(arrLi1));

 


全部清除

this.xxx = [];
localStorage.removeItem('searchLI');

推荐阅读