Answer the question
In order to leave comments, you need to log in
How to pass value to dispatch vuex?
Here is the code
import { Store } from "vuex";
export default {
async asyncData({ store, params }) {
await store.dispatch("getPosts");
await store.dispatch("getComment",1); // как передать значение которое находится в postId? если через this.postId не работает
return {
post: store.getters.posts,
comments: store.getters.comments
};
},
created: function() {
var postId = this.$route.params.id;
this.post = this.post[postId - 1];
console.log(params);
}
};
Answer the question
In order to leave comments, you need to log in
async asyncData({ store, params }) {
await store.dispatch("getPosts");
await store.dispatch("getComment", params.id);
return {
post: store.getters.posts,
comments: store.getters.comments
};
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question