1.0.3 • Published 6 years ago
rcc-lasting v1.0.3
#rcc-lasting
vuex持久化 可以使用sessionStorage,localStorage来分别存储
##Installation
$ npm install rcc-lasting -S
##Usage
import lasting from 'rcc-lasting'
const store = new Vuex.Store({
// ...
plugins: [lasting()]
})
分别使用sessionStorage,localStorage来存储响应的数据
import lasting from 'rcc-lasting'
const store = new Vuex.Store({
state:{
a:'',
b:''
}
// ...
plugins: [lasting({
Ls:['a'], //state.a 存储到localStorage
Ss:['b'] //state.b 存储到sessionStorage
})]
})
Nuxt.js
// nuxt.config.js
...
plugins: [{ src: 'plugins/storeLasting.js', ssr: false }]
...
// plugins/storeLasting.js
import lasting from 'rcc-lasting'
export default ({ store }) => {
lasting(
{
key: 'vuex',
Ls:['a'], //state.a 存储到localStorage
Ss:['b'] //state.b 存储到sessionStorage
}
)(store)
}
##API
lasting(options)