good-storage插件的使用

嗯,这个插件的目的就是减少我们之前写localstorage的,之前还要解析对象啥的,这个直接用就行啦
Install

npm install good-storage

Usage

 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

set(key, val)
set storage with key and val

get(key, def)
get storage with key, return def if not find

remove(key)
remove storage with key

has(key)
determine storage has the key

clear()
clear all storages

getAll()
get all the storages

forEach(callback)
forEach the storages and call the callback function with each storage

感谢分享
https://www.npmjs.com/package/good-storage

猜你喜欢

转载自blog.csdn.net/qq_32963841/article/details/85706975