javascript Vuex101:行动和调度

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Vuex101:行动和调度相关的知识,希望对你有一定的参考价值。

const store = new Vuex.Store({
  state: {
    count: 0
  },
  mutations: {
    increment (state) {
      state.count++
    }
  },
  actions: {
    increment (store, photo) {
      store.commit('increment', photo)
    }
  }
})

// dispatch with a payload
store.dispatch('incrementAsync', {
  amount: 10
})

// dispatch with an object
store.dispatch({
  type: 'incrementAsync',
  amount: 10
})

以上是关于javascript Vuex101:行动和调度的主要内容,如果未能解决你的问题,请参考以下文章