vuex 部分模块数据持久化
作者:互联网
- 安装
vuex-persistedstate
npm install --save vuex-persistedstate
- admin.js
const state = {
name: '',
phone: '',
avatar: ''
}
const mutations = {
}
export default {
namespaced: true,
state,
mutations
}
- store/index.js
// ...
import createPersistedState from 'vuex-persistedstate'
import admin from './modules/admin'
const adminState = createPersistedState({
paths: ['admin']
paths: ['admin.name'] // admin.js中的'name'持久化
})
export default new Vuex.Store({
// ...
plugins: [adminState]
})
标签:持久,name,admin,js,模块,persistedstate,const,vuex 来源: https://www.cnblogs.com/simdot/p/14887114.html