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