boenfu / vuex-along

:memo: auto save and restore state for vuex
https://boenfu.github.io/vuex-along/
MIT License
259 stars 36 forks source link

vuex分模块写时想保存其中一个模块中state的数据失效,刷新后还是丢失 #7

Closed weixinfei123 closed 6 years ago

weixinfei123 commented 6 years ago

import Vue from 'vue' import Vuex from 'vuex' import vuexAlong from 'vuex-along'

// 公共数据管理 import com from './modules/common.js'

import home from './modules/home.js'

import cardpageinfo from './modules/cardPageInfo.js'

import usercenter from './modules/usercenter.js'

import addOilCard from './modules/add_oil_card.js'

Vue.use(Vuex);

vuexAlong.watch([com.state.test], true)

export default new Vuex.Store({ modules: { com, home, cardpageinfo, usercenter, addOilCard }, plugins: [vuexAlong] })

我只想保存com.state.test这个数据,vuexAlong.watch([com.state.test], true) 这样写不起作用,第一次用,请问这个该怎么处理了,谢谢!

boenfu commented 6 years ago

直接模块名就好啦 vuexAlong.watch([‘test’], true) 记得带引号

weixinfei123 commented 6 years ago

vuexAlong.watch([‘test’], true)之前试过呀,刚刚也试了一下,还是不行了,刷新后还是变回初始值

weixinfei123 commented 6 years ago

vuexAlong.watch([‘com’], true)这样就可以了,刚才是模块名搞错了,谢谢