localStorage的存储、获取、删除操作

var store={
// 保存
save:function(key,value){
localStorage.setItem(key,JSON.stringify(value));
},
// 获取
fetch:function(key){
return JSON.parse(localStorage.getItem(key)) || [];
},
delete: function (key) {
localStorage.removeItem(key);
}

};
批量删除localStorage: localStorage.clear(); 
posted @ 2017-05-30 23:51  伊优  阅读(1967)  评论(0编辑  收藏  举报