mapGetters 辅助函数
mapGetters 辅助函数仅仅是将 store 中的 getter 映射到局部计算属性:
import { mapGetters } from 'vuex'
export default {
// ...
computed: {
// 使用对象展开运算符将 getter 混入 computed 对象中
...mapGetters([
'doneTodosCount',
'anotherGetter',
// ...
])
}
}
官网介绍
https://vuex.vuejs.org/zh/guide/getters.html
查看博客
- https://blog.csdn.net/gao_xu_520/article/details/79694148
- https://blog.csdn.net/youzhiningo/article/details/79640388