Doubts about the use of props in vue

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

  1. the parent component gets the list of articles and comments and then passes in the child components through props , and the article id and the method of posting comments also pass in the child components
  2. through props < / comment >.
  3. 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
  4. directly through store.state.
May.17,2022

recommends the second, which can reduce the coupling between components. In addition, the requested function is also recommended to be placed in a unified directory of the request function, which helps to separate the model layer from the props layer.


passing through the props will increase the coupling of the components. Components should be independent. Since the id exists in the store, it should be taken with store, and there is no need to take it out of the parent component and pass it to the child components.


I was also the first one before, but the background request to the data sub-component does not update the view


Why does this kind of data need to be stored with vuex ? do I need global sharing?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf5971-31f7a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf5971-31f7a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?