In vue, the parent component passes the value to the child component through props. How can the value in props be obtained in the methods in the child component?

Mar.05,2021

this.name can be obtained directly. It is understandable to write {{name}}


directly on the
page as the value is the same as in data .


the value passed through this method may not be available in the subcomponent mounted function if you get it directly. Because the value of the parent component has not been passed yet, but if you get the value in the method written in methods, the value has been passed and can be obtained directly using this.name.

if you want to get the passed value in the mounted () of a subcomponent, you'd better delay or listen, but one thing is why I have no problem using {{name}} in the page! This is the advantage of vue. It will be updated when the value of the name changes. That's why I saw the display. (in fact, it is empty at first, and then the value is passed, and it will be loaded.)

(Note: the above statement has changed this value in the parent component. If the value in the parent component is already the value in data and has not changed, then the above statement is not true.)

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-1e97b5e-47440.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-1e97b5e-47440.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?