一、store(仓库)
包含 state 和 mutations,通过提交(commit) mutations 改变 state
二、state(状态)
Vuex 使用 单一状态树 —— 是的,用一个对象就包含了全部的应用层级状态
问题:如何在Vue 组件中获得 Vuex 状态?(https://vuex.vuejs.org/zh-cn/state.html)
三、getters
可以认为是 store 的计算属性,接受 state 作为其第一个参数,使用 store.getters 或者 this.$store.getters 获取。
四、mutations
有一个字符串的 事件类型 (type) 和 一个 回调函数 (handler),回调函数会接受 state 作为第一个参数,传入 payload 当第二个参数,payload是一个对象。
五、action
类似于 mutation,不同在于:
Action 提交的是 mutation,而不是直接变更状态。
Action 可以包含任意异步操作。