NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
在组件xx.vue文件中取值 ``` 第一种 computed:{ count(){ return this.$store.state.count } count1(){ return this.$store.state.count1 } } ``` 简写xx.vue文件中 ``` 第二种 import { mapState } from"vuex" computed:mapState({ count : 'count', count1 : 'count1' }) ``` ``` 第三种 computed : mapState({ ['count','count1'] }) 哪如果要计算其他怎样办? ``` ``` ...{ count(){ return this.$store.state.count } count1(){ return this.$store.state.count1 } } computed :{ total(){ return this.arr.reduce((prev,curr)=>{ return curr + prev }) } ...mapState(['count','count1']) } ```