Universal Storage Utilities for Nuxt.js
$ cnpm install nuxt-universal-storage
Universal Storage Utilities for Nuxt.js based on @nuxt-community/auth-module
nuxt-universal-storage
dependency using yarn or npm to your projectyarn add nuxt-universal-storage
OR
npm install nuxt-universal-storage --save
nuxt-universal-storage
to modules
section of nuxt.config.js
{
modules: [
'nuxt-universal-storage',
],
storage: {
}
}
Options are defined as following:
storage: {
vuex, // boolean or {namespace}
localStorage, // boolean or {prefix }
cookie, // boolean or {prefix, options }
initialState, // Object {}
ignoreExceptions //
}
and default to
{
vuex: {
namespace: 'storage'
},
cookie: {
prefix: '',
options: {
path: '/'
}
},
localStorage: {
prefix: ''
},
ignoreExceptions: false,
}
$storage.getUniversal(key)
$storage.setUniversal(key, value)
$storage.syncUniversal(key, defaultValue)
$storage.removeUniversal(key)
$storage.getState(key)
$storage.setState(key, value)
$storage.removeState(key)
$storage.watchState(key, fn)
$storage.getLocalStorage(key)
$storage.setLocalStorage(key, value)
$storage.removeLocalStorage(key)
$storage.getCookies()
$storage.getCookie(key)
$storage.setCookie(key, value)
$storage.removeCookie(key)
yarn install
or npm install
yarn run dev
or npm run dev
http://localhost:3000
MIT License - Alibaba Travels Co
Copyright 2014 - 2016 © taobao.org |