相关疑难解决方法(0)

如何在具有不同命名空间的情况下访问具有相似名称的 vue/vuex mapActions 方法?

这工作得很好。

created() {
  this['shared/getPosts']();
  this['posts/getPosts']();

},

methods: {
  ...mapActions(['shared/getPosts', 'posts/getPosts']),
},
Run Code Online (Sandbox Code Playgroud)

但是,我想知道,有没有办法让下面的代码按预期工作,请参考评论:

created() {
  this.getPosts(); // triggers last method
},

methods: {
  ...mapActions('shared', ['getPosts']), // how to trigger this?
  ...mapActions('posts', ['getPosts']), // this gets triggered.
},
Run Code Online (Sandbox Code Playgroud)

javascript vue.js vuex

8
推荐指数
1
解决办法
2785
查看次数

标签 统计

javascript ×1

vue.js ×1

vuex ×1