Vuex use and points to note

vuex Vue is supporting public administration data tools, he can share some data, save it to vuex, any component of the entire program to facilitate direct access or modify public data

1, the state data can not be directly modified, if you want to modify, must passmutations

2, if the component you want to get data directly from the state: the need this.$store.state.***

3, if the components you want to modify data, you must use the  mutations methods provided, need this.$store.commit('方法的名称', 唯一的一个参数)

4, if the data on the state store, in time to provide both the need 做一层包装, then, is recommended getters, if need  , use gettersthis.$store.getters.***

Guess you like

Origin www.cnblogs.com/xsx123-/p/12382610.html
Recommended