sd-browser-storage
v1.2.0
Published
水滴前端存储库
Downloads
3
Readme
type
localStorage 和 sessionStorage存储库,具有相同的API
Usage
const {local, session} = require('sd-browser-storage');
// local实例,于session相同
// 存储及获取
local.setItem('key1', 1)
local.getItem('key1') // 1
local.setItem('key2', true)
local.getItem('key2') // true
local.setItem('key3', {a:1})
local.getItem('key3') // {a:1}
local.setItem('key4', ['a'])
local.getItem('key4') // ['a']
local.getItem('key5', 'default') // 'default'
// 删除key
local.removeItem('key5')
// 清空
local.clear()