使用localStorage缓存用户的较固定信息城市和小区(城市和小区均为select列表形式)

var cache= {} ;  //声明存放缓存的对象

cache.city = userCity ; //存储城市列表

cache.community = userCommunity ; //存储小区列表

cache.cityId = cityId; //城市id

cache.communityId = communityId ;  //小区id

//将cache对象转换为字符串格式 进行缓存

localStorage.setItem('cache',JSON.stringify(cache));

 

//取出缓存的对象

var obj = {}; 

obj = JSON.parse(localStorage.getItem("cache"));

posted @ 2016-08-31 16:14  co喵儿  阅读(219)  评论(0编辑  收藏  举报