Vuex官方文档:组合Action
https://vuex.vuejs.org/zh/guide/actions.html#组合-action

// 假设 getData() 和 getOtherData() 返回的是 Promise

actions: {
  async actionA ({ commit }) {
    commit('gotData', await getData())
  },
  async actionB ({ dispatch, commit }) {
    await dispatch('actionA') // 等待 actionA 完成
    commit('gotOtherData', await getOtherData())
  }
}

Returning Promises from Vuex actions
https://stackoverflow.com/questions/40165766/returning-promises-from-vuex-actions

ES6 Promise 参考
https://es6.ruanyifeng.com/#docs/promise

曾经做过的Promise 笔记
https://blog.csdn.net/sinat_34524528/article/details/90551620

Logo

前往低代码交流专区

更多推荐