Vuex
前端开发 IT 技术知识导航
知识导航面板
知识速览
为什么 Vue 需要集中式状态管理
- Props Drilling 之痛与集中式状态的解决思路
- Vuex 4 vs Pinia:为什么官方推荐迁移
- 单一状态树(Single State Tree)模型
选型决策:新项目该用 Vuex 还是 Pinia
- 新项目应该直接用 Pinia 的理由
- 维护中的 Vuex 项目何时该迁移
核心机制:state / getter / mutation / action
- mutation(同步变更)vs action(异步操作)
- state(响应式状态存储)与 mapState 辅助
- module 模块化与 namespacing
学习路线
插件与工具
- Vue DevTools 状态调试
- 插件系统(subscribe / subscribeAction)
- vuex-persistedstate 持久化插件
基础概念
- state / getter / mutation / action 基础用法
- 组件中使用 mapState / mapGetters / mapActions
- 安装与 createStore 创建 store
模块化与大型应用
- 动态模块注册(registerModule)
- Module 模块化拆分(按功能域拆分 store)
- 命名空间(namespaced: true)与跨模块访问
调试与常见问题
- TypeScript 类型推导困境(Vuex 4 的类型局限)
- 严格模式(strict: true)与 mutation 未追踪警告
向 Pinia 迁移
- Vuex → Pinia 概念映射(state/getters/actions 对应关系)
- 逐模块迁移策略(共存 → 替换)
资源库
替代方案
- Pinia(Vue 官方推荐的状态管理)
延伸资源
- Pinia 迁移指南
官方资源
- Vuex 官方文档