状态管理: Vuex

由于 store 中的状态是响应式的,在组件中调用 store 中的状态简单到仅需要在计算属性中返回即可。
触发变化也仅仅是在组件的 methods 中提交 mutation。

1. {{msg}}
{{this.$store.state.count}}
store.commit('increment')
console.log(store.state.count) // -> 1
2. 由于 Vuex 的状态存储是响应式的,从 store 实例中读取状态最简单的方法就是在计算属性中返回某个状态
{{count}}
my-counter =
countAlias={{countAlias}}

localCount={{localCount}}
countPlusLocalState={{countPlusLocalState}}