Vuex Action vs Mutations

前端 未结 13 1100
囚心锁ツ
囚心锁ツ 2020-12-02 04:37

In Vuex, what is the logic of having both \"actions\" and \"mutations?\"

I understand the logic of components not being able to modify state (which seems smart), but

13条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 05:07

    Mutations are synchronous, whereas actions can be asynchronous.

    To put it in another way: you don't need actions if your operations are synchronous, otherwise implement them.

提交回复
热议问题