export default{
set(key,data,time){
let obj={
data=data,
ctime:(new Date()).getTime(),//时间戳,同Date.now()
express:1000*60*60//设置过期时间一个小时
}
localStorage.setItem(key,JSON.stringify(obj));
},
get(key){
let obj=JSON.parse(localStorage.getItem(key));
let getItem=(new Date()).getTime();
if(getItem-obj.ctime>=express){
localStorage.removeItem(key);
return null;
}else{
return obj.data;
}
}
}