javascript - vuex parameter destructuring problem
给我你的怀抱
给我你的怀抱 2017-06-26 10:53:45
0
3
794

When I was using vuex, I saw parameter destructuring used, but I was wondering, where did this commit come from? Where is the commit parameter provided? How is it written without simplification?

actions: { increment ({ commit }) { commit('increment') } }
给我你的怀抱
给我你的怀抱

reply all (3)
魑魅魍魉

actions: {

increment (context) {

context.commit('increment'),

},

ddd(context) {

context.commit('ddd'),

}

}

用参数解构之后:

actions: {

increment ({ commit }) {

commit('increment')

},

ddd({ commit }) {

commit('ddd')

}

}


    代言
    actions: { increment ( object ) { object.commit('increment') } }
      Ty80

      The

      Action function accepts a context object with the same methods and properties as the store instance, so you can call context.commit
      to submit a mutation, or get state and
      getters via context.state and context.getters. When we introduce Modules later, you will know why the context object is not the store instance itself.

      vuex documentation

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!