We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
相当于 Vue 的 data 对象
data
store
mapState
相当于 Vue 的 computed 对象
computed
Vuex允许在store中定义getter。
store.getters
this.$store.getters.XXX
mapGetters
mutation handler
可以像 store.commit中传入额外参数, 即 mutation的载荷
mutation
store.commit('increment', 10) increment (state, payload)
Action 函数接受一个与 store 实例具有相同方法和属性的 context 对象,因此你可以调用 context.commit 提交一个 mutation,或者通过 context.state 和 context.getters 来获取 state 和 getters。但是 context对象并不是 store 实例本身
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Vuex与全局变量的区别:
Vuex的几个核心概念
state
相当于 Vue 的
data
对象store
实例。mapState
辅助函数Getter
相当于 Vue 的
computed
对象Vuex允许在store中定义getter。
store.getters
对象this.$store.getters.XXX
mapGetters
辅助函数Mutation
mutation handler
提交载荷(Payload)
可以像 store.commit中传入额外参数, 即
mutation
的载荷Action
Action 函数接受一个与 store 实例具有相同方法和属性的 context 对象,因此你可以调用 context.commit 提交一个 mutation,或者通过 context.state 和 context.getters 来获取 state 和 getters。但是 context对象并不是 store 实例本身
The text was updated successfully, but these errors were encountered: