作为方法使用
默认使用 window.localStorage
如果要使用sessionStorage,请使用store.session
npm i xr-storage --save
...
import store from 'xr-storage'
// 默认使用localStorage
store({method:'get',key:'testKey'})
// 使用sessionStorage
store.session({method:'get',key:'testKey'})
设置-set
// key 为字符串类型, value为任意类型,
//如果value不存在,将移除这个key
store({method:'set',key:'testKey',value:'testValue'})
获取-get
// key 为字符串类型
store({method:'get',key:'testKey'})
获取所有-getAll
// 返回值为对象
store({method:'getAll'})
是否有-has
// key 为字符串类型,返回值为布尔值
store({method:'has',key:'testKey'})
移除-remove
// key 为字符串类型
store({method:'remove',key:'testKey'})
清空-clear
store({method:'clear'})