2.3 Vuex核心概念及底层原理

一、核心概念

  1. State:this.$store.state.xxx,取值

  2. Getter:this.$store.getters.xxx,取值

  3. Mutation:this.$store.commit("xxx"),赋值

  4. Action:this.$store.dispatch("xxx"),赋值

  5. Module

二、底层原理

  1. State:提供一个响应式数据

  2. Getter:借助Vue的计算属性computed来实现缓存

  3. Mutation:更改state方法

  4. Action:触发mutation方法

  5. Module:Vue.set动态添加state到响应式数据中心

Last updated