javascript - What is the correct way to write vuex's mapState to coexist with other computed properties?
为情所困
为情所困 2017-05-16 13:24:52
0
1
860

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?

为情所困
为情所困

reply all(1)
过去多啦不再A梦

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!