commit | author | age | ||
bf6fbe | 1 | import Vue from 'vue' |
L | 2 | import Vuex from 'vuex' |
3 | Vue.use(Vuex) | |
4 | ||
5 | const state = { | |
6 | // 初始化A和B组件的数据,等待获取 | |
7 | AMsg: '', | |
8 | BMsg: '' | |
9 | } | |
10 | ||
11 | const mutations = { | |
12 | receiveAMsg(state, payload) { | |
13 | // 将A组件的数据存放于state | |
14 | state.AMsg = payload.AMsg | |
15 | }, | |
16 | receiveBMsg(state, payload) { | |
17 | // 将B组件的数据存放于state | |
18 | state.BMsg = payload.BMsg | |
19 | } | |
20 | } | |
21 | ||
22 | export default new Vuex.Store({ | |
23 | state, | |
24 | mutations | |
25 | }) |