前段存储的调用函数

//items:items({name:1,age:13,phone:12})//传参数
(function(win,doc){
var GD16={
items:function (arguments){//这个是用于存和取值的函数
if(typeof arguments=='object'){
for(var i in arguments){
window.localStorage.setItem(i,arguments[i]);
}
}else if(typeof arguments=='string'){
return window.localStorage.getItem(arguments);//获取

}else{
return console.error('参数只能是json,或者string')
}
},
removeitem:function (val){
if(val){
window.localStorage.removeItem(val);
}else{
var json=window.localStorage(val);
for(var i in json){
window.localStorage.removeItem(i);
}
}
}
};win.GD16=GD16;

})(window,document);

原文地址:https://www.cnblogs.com/deng-00/p/6912533.html