lafitewu

Vue storage collection

cookie、session、storage封装

Version Version: 1.0.1 Version Updated: 05/23/2022 By: lafitewu License: MIT

DownloadsLast30Days: 6

npm i vue-storage-collection
yarn add vue-storage-collection

vue-storage-collection

cookie、session、storage 集合简化封装

基于vue

# install dependencies
npm install vue-storage-collection -s

# main.js 全局引入及使用
import storageCollection from 'vue-storage-collection'
Vue.use(storageCollection)

# index.vue
<div>{{$sessionGet('xx')}}</div>

获取sessionStorage => $sessionGet(key)
设置sessionStorage => $sessionSet(key,val)
清除sessionStorage => $sessionClear(key)    ps: 当key值不传时,则是清空所有sessionStorage

获取localStorage => $storageGet(key)
设置localStorage => $storageSet(key,val)
清除localStorage => $storageClear(key)    ps: 当key值不传时,则是清空所有localStorage

获取cookie => $cookieGet(key)
设置cookie => $cookieSet(key,val)
清除cookie => $cookieClear(key)    ps: key为必填项,否则无效
Categories: StorageUtilities
Tags:

Copyright © 2020 vuejscomponent.com