The difference and use of
Code example:
this.$('loginStatus', 1); this.$('isLogin', true);
Standard usage
// in the form of load('increment',{ amount: 10 //This is an extra parameter}) // Or use object-style submission method({ type: 'increment', amount: 10 //This is an extra parameter})
Key differences
dispatch
: Contains asynchronous operations, data is submitted to actions, which can be used to submit data to the background
this.$('isLogin', true);
commit
: Synchronous operation, data submitted to mutations, can be used to read user information and write it to the cache
this.$('loginStatus', 1);
this.$() and this.$()
The mutation of the value to vuex changes state
commit
: Synchronous operation
- storage
this.$('changeValue',name)
- Get the value
this.$
dispatch
: Asynchronous operation
- storage
this.$('getlists',name)
- Get the value
this.$
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.