1.0.3 • Published 6 years ago

rcc-lasting v1.0.3

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

#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)

  • key <String> : 本地存储的key名称。(默认:vuexStorage)
  • Ls <Array> : 需要存到localStorage的key。(默认:
  • Ss <Array> : 需要存到sessionStorage的key。(默认:
1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago