commit: 同步操作
this.$store.commit('方法名',值)【存儲】
this.$store.commit('newBankName', this.textValue)
this.$store.state.方法名【取值】
dispatch: 異步操作
this.$store.dispatch('方法名',值)【存儲】
this.$store.getters.方法名【取值】
當操作行為中含有異步操作,比如向后臺發(fā)送請求獲取數(shù)據(jù),就需要使用action的dispatch去完成了。
其他使用commit即可。
其他了解:commit=>mutations,用來觸發(fā)同步操作的方法。
dispatch =>actions,用來觸發(fā)異步操作的方法。在store中注冊了mutation和action,在組件中用dispatch調(diào)用action,然后action用commit調(diào)用mutation,
Getter 會暴露為 store.getters 對象,你可以以屬性的形式訪問這些值: