vuex的三个辅助函数用法

//引入辅助函数
import {mapMutations,mapState,mapActions} from 'vuex'
  export default {
    computed: {
      ...mapState({
        loginFlag: state => state.currentinfo.loginFlag
      }),
    },
    methods: {
      ...mapActions({
        getCurrentInfo: "getCurrentInfo"
      }),
      //若 namespaced: true 命名空间
      ...mapActions({
        getCurrentInfo: "currentinfo/getCurrentInfo"
      }),
    },
  }

mapMutations用法同mapActions

你可能感兴趣的:(vue)