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

Vuex中actions和mutations有什么区别? #123

Open
GGXXMM opened this issue Apr 1, 2022 · 0 comments
Open

Vuex中actions和mutations有什么区别? #123

GGXXMM opened this issue Apr 1, 2022 · 0 comments
Labels

Comments

@GGXXMM
Copy link
Owner

GGXXMM commented Apr 1, 2022

概念区别

  1. 更改 Vuex 的 store 中的状态唯一方法是提交 mutationmutation非常类似于事件:每个 mutation 都有一个字符串的类型(type)和一个回调函数(handler)。
  2. action 类似 mutation,不同在于:
  • action 提交的是 mutation,而不是直接变更状态
  • action 可以包含任意异步操作

应用场景区别

使用细节不同

实现本质上的差异

@GGXXMM GGXXMM added the vue label Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant