扫码关注官方订阅号
这样搞的很混乱啊,一会儿是this.$store.state.模块.状态名,一会儿是this.$store.getter.获取器名。
有啥办法能够让getter也像状态一样必须按模块调用吗?
vuex模块内部的 action、mutation、和 getter 默认是注册在全局命名空间
中文的文档没更新,英文文档已经介绍了namspaced属性了,应该是从2.1.0版本开始支持
这个issue又介绍了以后的namespace属性
getter写在模块里面
getter
const moduleA = { state: { ... }, mutations: { ... }, actions: { ... }, getters: { ... } } const moduleB = { state: { ... }, mutations: { ... }, actions: { ... } } const store = new Vuex.Store({ modules: { a: moduleA, b: moduleB } }) store.state.a // -> moduleA 的状态 store.state.b // -> moduleB 的状态
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
vuex模块内部的 action、mutation、和 getter 默认是注册在全局命名空间
中文的文档没更新,英文文档已经介绍了namspaced属性了,应该是从2.1.0版本开始支持
这个issue又介绍了以后的namespace属性
getter写在模块里面