I did several VUE projects, but I didn’t use VUEX all the time, and I was always worried that I would use it someday. So I secretly paddled a wave of water to learn VUex during working hours.
As the official documentation has made it quite clear, this article is only for my personal understanding notes.
Look at the components
- State ==> is approximately equal to data in the component, storing data
- Mutations ==> is approximately equal to synchronous methods and commit trigger events in the component
- Actions ==> is approximately equal to asynchronous events in the component, and dispatch triggers events
- Getters ==> is approximately equal to computed in the component
export default new Vuex.Store({
state: {//data
name:'zs'
},
mutations: {// Synchronize methods commit trigger
changeName(state,str){
return state.name+=str
}
},
actions: {// Asynchronous methods dispatch trigger
},
getters: {//computed
},
modules: {//}})Copy the code