Store.dispatch
分发 action。返回一个解析所有被触发的 action 处理器的 Promise。详细介绍
参数说明
| 参数 | 类型 | 必填 | 说明 | 
|---|---|---|---|
| type | String | 是 | 类型 | 
| payload | any | 否 | 载荷,传入的额外参数 | 
示例
// store.js
import createStore from 'chameleon-store'
const store = createStore({
  state: {
    count: 0
  },
  mutations: {
    increment (state) {
      state.count++
    }
  },
  actions: {
    incrementAsync ({ commit }) {
      setTimeout(() => {
        commit('increment')
      }, 1000)
    }
  }
})
export default store
// app.js
store.dispatch('incrementAsync')
