[Vuex] 中不推荐-return-data

34 阅读1分钟
  1. forum.vuejs.org/t/vuex-disp…
1. Don’t return the data from the action. Your mutation saves it in the store’s state, so that’s eh ew you ago of get it from.
2. No need to wrap axios in a Promise, axios returns a promise itself already.
  1. 一次性调用多个dispatch,等所有的dispatch返回数据,执行callback
Promise.all([
    this.$store.dispatch('A'),
    this.$store.dispatch('B')
 ]).then(([aResult, bResult]) => {
    // 讨论 dispatch中是否返回数据??
    // do something
})