Why use vuex instead of using global variables directly

vuex is a globally operable data warehouse, but what"s the difference between it and global variables?

Apr.20,2022

refer to my previous answer: use vuex instead of window.obj to maintain global instance properties and methods

it's okay to use global variables at the initial stage. If the project is complex, you have to encapsulate and optimize the global variables, make it more convenient to call, directly modify the data, you can render the view, and so on. This process is actually repeated making wheels

.

Global can be used when the amount of data is small, but as an application (app), the amount of data is very large. In fact, you can also write the local global without database. Which do you think is better?


if a project has 1000 pages, I can use vuex to create a separate store for each page, and entering the same page again after leaving will create a new store without interference. And how to monitor changes in variables that are not within the framework?
what do you do with global variables?

Menu