Vue中 关于 ‘...mapGetters’的了解

首先,我们应该知道getters是vuex中的特殊表达部分

不使用map辅助函数:

  computed: {
    test:()=> this.$store.getters.doSome
  }   

使用map辅助函数:

  computed: {
    ...mapGetters({
      'test': 'doSome'
    })
  }

似乎看起来使用map辅助函数更麻烦,其实不然,当我们调用多个getters的时候

  computed: {
    ...mapGetters({
      'tes1t': 'doSome1''test2':'doSome2',
      'user': 'user'
    })
  }

这样更方便

参考资料>>>

原文地址:https://www.cnblogs.com/adongyo/p/12109282.html