不管是mapState还是mapMutations还是mapActions等等,都是语法糖,为了加快代码效率而已
mapState
import {
mapState} from 'vuex'
export default {
name: 'home',
computed: mapState(['nickname','age','gender'])
}
mapState(['nickname','age','gender'])
这一句代码就相当于下面这些
nickname(){
return this.$store.