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