9记账 Vue 项目-Vue 全局数据管理(下)之 Vuex

141 阅读1分钟

9.1 Vuex初体验 - 数据读写

Vuex就是专为 Vue.js 应用程序开发的数据读写工具

  1. state就是数据
  2. mutations就是对数据的改动
  3. commit就是调用mutations里的操作(以字符串的形式)

与vue不同,它需要通过commit来触发事件

Vue.use(Vuex)会在Vue的原型上绑定一个共用属性,把store绑到Vue.prototype上

Vue.prototype.$store = store

9.2 在Money.vue中使用Vuex

9.3 重构Tags.vue和Labels.vue

9.4 在TS里面使用mixin

9.5 重构EditLabel.vue

9.6 在TS里使用computed要用getter语法

9.7 继续重构EditLabel.vue

9.8 Vuex总结