Article.vue
is the parent component, and ArticleComments.vue
is the child component, which posts comments and displays a list of comments. article id
, article id
exists in vuex state
, which of the following two ways is better
- the parent component gets the list of articles and comments and then passes in the child components through
props
, and thearticle id
and the method of posting comments also pass in the child components through - does not use props, and the sub-component makes the request by itself, and the required method is defined in the sub-component. The article id also obtains directly through store.state.
props < / comment >.