good-storage 使用

2019-05-31  本文已影响0人  oYang_Mr

官方地址:https://www.npmjs.com/package/good-storage

安装

npm install good-storage

用法

import storage from 'good-storage'

// localStorage
storage.set(key,val)
storage.get(key, def)

// sessionStorage
storage.session.set(key, val)
storage.session.get(key, val)

API
  1. set storage with key and val
    set(key, val)
  2. get storage with key, return def if not find
    get(key, def)
  3. remove storage with key
    remove(key)
  4. determine storage has the key
    has(key)
  5. clear all storages
    clear()
  6. get all the storages
    getAll()
  7. forEach the storages and call the callback function with each storage
    forEach(callback)
上一篇 下一篇

猜你喜欢

热点阅读