The official example usage of mapState is:
computed:mapState(['count'])
How should we write other computed attributes that do not require state? I tried
computed:{mapState(['count']), age(){return this.old_age + 1;}}
will report an error
computed:mapState(['count', age(){return this.old_age + 1;}])
will also report an error, even
computed:{mapState(['count'])}
Will report an error. What is the correct way to write it?
Can you read the official vuex documentation before asking?
computed: { localComputed () { / ... / },
// Use the object spread operator to mix this object into an external object
...mapState({ // ... })
}
If you don’t know what the object spread operator is, please check the es6/7 documentation