When should I use Vuex?

前端 未结 4 724
梦毁少年i
梦毁少年i 2020-12-07 00:02

Now I start to learn vue, and I\'m creating SPA for editing database. Now I can\'t understand where I should use a Vuex. I can use props and $emit everywhere an

4条回答
  •  余生分开走
    2020-12-07 00:47

    Yes, you can do anything without the use of Vuex, but with time, if your application is getting larger then it would be difficult to maintain,

    according to vuex documentation,

    problem one, passing props can be tedious for deeply nested components, and simply doesn't work for sibling components. problem two, we often find ourselves resorting to solutions such as reaching for direct parent/child instance references or trying to mutate and synchronize multiple copies of the state via events. Both of these patterns are brittle and quickly lead to unmaintainable code.

    Hope it answers your question.

提交回复
热议问题