# lyq **Repository Path**: qalanber/lyq ## Basic Information - **Project Name**: lyq - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: li - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-04-26 - **Last Updated**: 2022-07-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## vuex ### 初始化操作(类似路由) ### vuex的使用 1. 多组组件公用全局状态 在state的数据 任何组件都可以使用 2. 全局状态发生改变所有的组件都会自动更新 commit -> mutations 来修改state ### 基本版本 1. state 里添加全局状态值 2. 组件里 通过 this.$store.state 使用全局状态值 3. state的修改只能通过mutation的方法 4. mutations内部的方法通过commit 触发 this.$store.commit('mutions得方法',参数) ### 版本1.5 1. state 里添加全局状态值 2. 组件里 通过 this.$store.state 使用全局状态值 3. state的修改只能通过mutation的方法 4. mutations内部的方法通过commit 触发 this.$store.commit('mutions得方法',参数) 6. 在组件内部通过dispatch 触发 actions里的方法 7. actions 内部通过 commit 触发mutation actions使用的场景 1. 合并commit操作 2. 存放异步 ### 版本2.0 通过辅助函数优化调用体验 mapState mapActions mapGetters mapMutations mapState('moduleName',arrary|obj) mapActions('moduleName',arrary|obj) mapGetters('moduleName',arrary|obj) mapMutations('moduleName',arrary|obj) 参数为数组 将全局状态里的方法和值 直接映射到 computed 和 methods里 参数为对象 将全局状态里的方法和值 改名之后 映射到 computed 和 methods里 ### 版本2.5版本 模块化 通过modules 根据功能模块将全局状态值 拆分 只有 state 拥有模块名, 通过 namespaced:true action mutation getters 赋予模块名 在使用时需要添加模块名 ### git commit -m 'xxx:desc' feat: 功能增加 style: 样式修改 doc: 文本 config: 配置