[vue] why do you want to use vuex instead of window.obj to maintain global instance properties and methods

  javascript, vue.js

[vue] why do you want to use vuex instead of window.obj to maintain global instance properties and methods?

Then why don’t you use the originalJsFor development purposesvue?
Here we gowindow.objUse development as an example

window.obj = {
 count: 1,
 todos: [
 { id: 1, text: '...', done: true },
 { id: 2, text: '...', done: false }
 bracket
 bracket

If you want to modify the status

//a component
 Window.obj.count plus =1;
 //b component
 Window.obj.count =5;
 //c component
 window.obj.count=10;

The above method certainly cannot be used, and it must be encapsulated into a method to modify in a complex program.
Then there isRegisterAnddispatch
in order todevtoolsEasy to track and debugvuexMade his own packageMutation CommitSuch that the state must be submitted synchronously atJsThere will definitely be asynchrony, so there isAction dispatchUsed for asynchronous operation

Like the above, you will find that the package is established when you do it.vuexOr similar state management