高洛峰2017-05-19 10:45:29
Trigger the increment in actions, context.commit("increment") triggers the increment function in mutations, this is the process
大家讲道理2017-05-19 10:45:29
I am also new to VuexNot long ago, let me briefly talk about my understanding.
Store
理解为一个仓库,action
是一次操作,mutation
是让仓库中存储的东西产生某种变化的方式,state
is the current status of the stored thing.
One operation may need to change the data, and another operation also needs to make the same change to the data. Then this change can be extracted and called a mutation
,这样,通过commit
触发指定的mutation
. There is no need to mix it with the code that operates the business, resulting in code The result is clutter and poor maintainability.