const PersistedState = { setStorage:(m,v)=>{ let storage=PersistedState.getStorage() if(typeof(storage)!='object'){ storage={} } if(typeof(storage[m])=='undefined'){ storage[m]={} } for(var k in v){ storage[m][k]=v[k] } uni.setStorage({ key:'dsmall', data:storage }) }, getStorage:(m,k,default_val=null)=>{ let storage=uni.getStorageSync('dsmall') if(typeof(m)=='undefined'){ return storage }else{ if(storage && typeof(storage[m])!='undefined' && typeof(storage[m][k])!='undefined'){ return storage[m][k] }else{ return default_val } } }, } export default PersistedState