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

Redux & Vuex #212

Open
teazean opened this issue Oct 8, 2018 · 0 comments
Open

Redux & Vuex #212

teazean opened this issue Oct 8, 2018 · 0 comments

Comments

@teazean
Copy link
Owner

teazean commented Oct 8, 2018

在 Redux 中, 分层为action -> reducer -> state; 在 Vuex 中,分层为 action -> mutation -> state

  • 相同点:action 为表示修改操作,不直接操作 state
  • 不同点:在 redux 中,每次 action 的执行是要返回一个新的完整的 state,通常需要执行所有的 reducers(每个 reducer 根据 acitonType 进行判断处理);在 vuex 中,每次 action 的执行是为了 直接修改当前的 state 对象,所以需要调用特定的 mutation 来操作 state,mutation 的定义是一个事务原子级别的。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant