0.2.2 • Published 5 years ago

vuex-solidification v0.2.2

Weekly downloads
2
License
ISC
Repository
-
Last release
5 years ago

vuex-solidification

Persist and rehydrate your Vuex state between page reloads. 中文文档

Requirements

Install

npm install --save vuex-solidification

Usage

import createPersistedState from 'vuex-solidification'

const store = new Vuex.Store({
  // default, use localstorage to save all state in vuex
  plugins: [createPersistedState()], 
})

// or
const store = new Vuex.Store({
  // just store the key in state
  plugins: [createPersistedState(
      local: {
          include: ['a.b.c'] // just store state.a.b.c use localStorage
      }
  )], 
})

// or
const store = new Vuex.Store({
  // just store the key in state
  plugins: [createPersistedState(
      local: {
          exclude: ['a.b.c'] // just store all value except state.a.b.c use localStorage
      }
  )], 
})

// or
const store = new Vuex.Store({
  // just store the key in state
  plugins: [createPersistedState(
      session: {
          include: ['a.b.c'] // just store state.a.b.c in sessionStorage
      }
  )], 
})

// or
const store = new Vuex.Store({
  // just store the key in state
  plugins: [createPersistedState(
      session: {
          exclude: ['a.b.c'] // just store all value except state.a.b.c use sessionStorage
      }
  )], 
})

// or 
const store = new Vuex.Store({
  // just store the key in state
  plugins: [createPersistedState(
      session: {
          include: ['a.b.c'] // store state.a.b.c in sessionStorage
      },
      local: {
          include: ['a.b.d'] // store state.a.b.c in localStorage
      }
  )], 
})

Check out the example on CodeSandbox.

Edit kmz9jx5ynr

API

createPersistedState({options})

Creates a new instance of the plugin with the given options. The following options can be provided to configure the plugin for your specific needs:

  • key <String>: The key to store the persisted state under. (default: vuex)

  • local <Object>: use localSrorage, Two optional values is include<Array> and exclude<Array> include<Array>: the value in include represents the value need to saved exclude<Array>: the value in exclude represents the value no need to saved

  • session <Object>: Same configuration as local

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago