vue.js和good-storage缓存


VUE.JS 缓存 good-storage :

good-storage 是一个插件,需要安装

localStorage 临时缓存(关闭浏览器自动销毁)

sessionStorage 长期缓存(主动清楚缓存才会销毁)

安装步骤:

在命令行安装

npm install good-storage

使用:

 1 import storage from 'good-storage'
 2 
 3 // localStorage
 4 storage.set(key,val) 
 5 
 6 storage.get(key, def)
 7 
 8 // sessionStorage
 9 storage.session.set(key, val)
10 
11 storage.session.get(key, val)
12 缓存的API
13 
14 set(key, val)
15 set storage with key and val
16 
17 get(key, def)
18 get storage with key, return def if not find
19 
20 remove(key)
21 remove storage with key
22 
23 has(key)
24 determine storage has the key
25 
26 clear()
27 clear all storages
28 
29 getAll()
30 get all the storages
31 
32 forEach(callback)
33 forEach the storages and call the callback function with each storage

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM