vuex 基本使用-待完善

1.调用vuex中的mutation中的方法
this.$store.commit('setEditUser', this.multipleSelection)
2.取出vuex中state的数据
this.$store.state.editUser

3.代码示例

const store = new Vuex.Store({
    state: {
        count:0
    },
    mutations: {
        // 加1
        INCREMENT(state) {
            state.count++;
        },
        // 减1
        DECREMENT(state) {
            state.count--
        }
    },
    actions: {
        increment(context) {
            context.commit("INCREMENT");
        },
        decrement(context) {
            context.commit("DECREMENT");
        }
    }

})


猜你喜欢

转载自blog.csdn.net/zpcqdkf/article/details/80535921