使用直接调用的getters
1.直接使用
this.$store.state.方法名称;
2.map辅助函数
computed: {
...mapGetters(['方法名称']),
...mapGetters({'新方法名字': '旧方法名称'})
}
使用modules中的getters
1.直接使用
this.$store.getters.模块名.方法名称
2.map辅助函数
computed: {
...mapGetters('模块名', ['方法名称']),
...mapGetters('模块名',{'新方法名字':'旧方法名称'})
}
小结--->在state中的数据的基础上,进一步对数据进行加工得到新数据。(与组件中computed一样)