import Vue from 'vue'
import 'es6-promise'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
    state: {
        num: 1,
        loading: false,
    },
    // 异步操作
    actions: {
        addNumActions(context, payload) {
            context.commit('addNumMutations', payload)
        },
        setLoadingActions(context, payload) {
            context.commit('setLoadingMutations', payload)
        },

    },
    mutations: {
        addNumMutations(state, payload) {
            state.num += payload
        },
        // 组件loading
        setLoadingMutations(state, payload) {
            state.loading = payload;
        }
    }
})
