这工作得很好。
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)