包含对象
state、mutations、getters、actions
state
Vuex 中的数据源,可以通过 this.$store.state.变量名 访问仓库的数据源
mutations
通过 this.$store.commit(‘方法名’) 修改仓库中的数据源信息,同步操作
getters
理解为 vue 中的 computed
actions
类似 mutations,异步操作
使用方法
1 | const state={ |
state、mutations、getters、actions
state
Vuex 中的数据源,可以通过 this.$store.state.变量名 访问仓库的数据源
mutations
通过 this.$store.commit(‘方法名’) 修改仓库中的数据源信息,同步操作
getters
理解为 vue 中的 computed
actions
类似 mutations,异步操作
1 | const state={ |