inner.js
export default inner = {
state: {
acDeviceId: null
},
mutations: {
setAcDeviceId(state, acDeviceId) {
state.acDeviceId = acDeviceId
}
},
getters: {
getAcId: state => state.acDeviceId
}
}
out.js
import inner from 'inner.js'
export default new Vuex.Store({
state: {
},
mutations: {
},
actions: {
},
modules: {
inner
}
})
上面的代码是全局注册的,然后在其他组件中this.$store.commit('setAcDeviceId', 10),结果看到acDeviceId仍然为null,为什么呢?我看到项目其他地方也是这样写的都没问题啊