Does the communication between vue father and son have to be handled by computed?

I saw a tutorial when I was watching brother correspondence. It said that prop should use computed to deal with father-son communication. As if I had seen other people"s father-son correspondence before, the tutorial did not say so. The small example of father-son communication that I wrote also did not use computed. So is this correct in the article? It seems that the vue document also mentioned that it is best to use this calculation property. Is that so?

vue

console.log
Apr.12,2021

Let's first come to a conclusion. This is reasonable and recommended, but it is not absolute. It still depends on the understanding and use of parent-child component communication.

when the parent and child components communicate, the data is transmitted unidirectionally, so that the data of the parent and child components can be isolated. Using computed, an object can be re-obtained as the internal data of the child component. When the data of the child component changes, it does not affect the state of the parent component. In addition, when the data in props does not conform to the format of the sub-component, computed can also convert the format.

but,

  1. when prop data will not be changed in subcomponents, such as just displaying a number, then it is not necessary to use computed , just use it directly.
  2. for an array or object type prop, changing the object or the array itself in the child component will affect the state of the parent component, so if you need the data Synchronize communicated by the parent and child components, you can do without computed. However, the official this.$emit () method is provided to pass the child component data to the parent component, so if you are not familiar with this piece, it is not recommended to use props directly.
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-1b36e4d-2c043.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-1b36e4d-2c043.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?