Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

165. vuex 中不推荐 return data #165

Open
ly525 opened this issue Oct 22, 2018 · 0 comments
Open

165. vuex 中不推荐 return data #165

ly525 opened this issue Oct 22, 2018 · 0 comments

Comments

@ly525
Copy link
Owner

ly525 commented Oct 22, 2018

  1. https://forum.vuejs.org/t/vuex-dispatch-action-is-this-correct/24824/2
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
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant