localStorage存对象

存数据

var obj = {"name":"ergouzi","age":"16"}
localStorage.setItem("userInfo",JSON.stringify(obj));

取数据

var user = JSON.parse(localStorage.getItem("userInfo"))

删除数据

localStorage.removeItem("userInfo);
posted @ 2021-12-12 17:30  山上小和尚  阅读(229)  评论(0编辑  收藏  举报