mapState的官方示例使用方法是:computed:mapState(['count'])那其它不需要state的computed属性应该怎么写呢?我试了computed:{mapState(['count']), age(){return this.old_age + 1;}}会报错computed:mapState(['count', age(){return this.old_age + 1;}])也会报错,甚至computed:{mapState(['count'])}都会报错 请问正确的写法应该是怎样的?
1 回答

回首忆惘然
TA贡献1847条经验 获得超11个赞
提问之前能不能看看vuex官方文档?
computed: { localComputed () { / ... / },
// 使用对象展开运算符将此对象混入到外部对象中
...mapState({ // ... })
}
如果不知道对象展开运算符是什么麻烦去查es6/7的文档
添加回答
举报
0/150
提交
取消