vuex辅助函数

我用mapActions mapGetters辅助函数去并发和获取数据
但是mapActions不会去自动并发也没有报错,而mapGetters却能获取的到值
this.$store.dispatch这种方式就一切都正常,这是怎么回事??

阅读 5.4k
2 个回答

mapActions 只是單純把 dispDeptList 給注入進當前組件的 methods 裡面,你還得去呼叫他 :

created() {
    this.dispDeptList()
}

mapActions只是生成一个方法,相当于:

methods:{
    dispDepList(){
        ...
    }
}

你要在你需要用到的地方去调用这个方法

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题