current position:Home>Properties and usage of vuex

Properties and usage of vuex

2022-04-29 04:29:10weixin_ forty-two million two hundred and fifty-four thousand a

vuex Properties and usage of

state、getters、mutations、actions、modules
state:vuex The basic data of , Used to store variables
getters: From the basic data (state) Derived data , amount to state Calculated attributes of
mutations: Method of submitting updated data , It has to be synchronized ( If you need to use asynchronously action). Every mutation There is a string of event types (type) And a callback function (handler)
action: and mutation The functions of are roughly the same , The difference is ==》1.Action Is submitted mutation, Instead of changing the state directly .2.Action You can include any asynchronous operation
modules: modularization vuex, Each module can have its own state、mutation、action、getters, Make the structure very clear , Easy to manage
dispatch: Contains asynchronous operations , For example, submit data to the background , How to write it : this. s t o r e . d i s p a t c h ( ‘ a c t i o n Fang Law name ’ , value ) c o m m i t : Same as Step fuck do , Write Law : t h i s . store.dispatch(‘action Method name ’, value ) commit: Synchronous operation , How to write it :this. store.dispatch(action Fang Law name , value )commit Same as Step fuck do , Write Law this.store.commit(‘mutations Method name ’, value )

copyright notice
author[weixin_ forty-two million two hundred and fifty-four thousand a],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/117/202204270551121971.html

Random recommended