js 简单本地缓存

var Cache={
type: 'session',
setType : function(){
if( this. type == 'session'){
return window. sessionStorage;
}
if( this. type == 'local'){
return window. localStorage;
}
console. log( '类型错误!');
},
set : function( $key, $value){
this. setType(). setItem( $key, $value);
},
get : function( $key){
return this. setType(). getItem( $key)
}
}

猜你喜欢

转载自blog.csdn.net/dragonlhp/article/details/80407483