Vuex内函数使用方法
1.state: state提供唯一的公共数据资源 所有共享的数据都要统一放在store中state存储
使用 this.$store.state.xxx
模块化的 this.$store.模块名称.xxx
2.mutations: state内数据的修改只能通过 mutations 并且 mutations 必须是同步的
组件使用 this.$store.commit('mutations内函数名',参数)
模块使用 this.$store.commit('模块名/mutations内函数名',参数)
3.actions: 负责进行异步操作
组件里面使用 this.$store.dispatch('actions内异步函数',参数)
4.getters: 依赖于 state的数据 比如求数组长度 数组过滤等等 一般用于计算
组件使用: this.$getters.xxx
5.module: 开发时 避免一个状态对象过大 拆分模块使用 需要一个方法 namespaced 开启命名空间