美文网首页
good-storage 使用

good-storage 使用

作者: oYang_Mr | 来源:发表于2019-05-31 14:58 被阅读0次

官方地址: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)

相关文章

网友评论

      本文标题:good-storage 使用

      本文链接:https://www.haomeiwen.com/subject/yeowtctx.html