vuex uses modules and namespaced

When there are many Vuex states, it needs to be divided into different modules, but after dividing the modules, the mutations, actions, and getters of different modules cannot have the same name, so namespaced should be introduced into the module.

 

commit to write like this

this.$store.commit('cart/addCart', $data);

 

cart is the module name

 

refer to

https://vuex.vuejs.org/en/modules.html#namespacing

https://segmentfault.com/q/1010000009900181/a-1020000009901235

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326079016&siteId=291194637