How does the parent component use the values in the child component when the vue child component does not trigger an event?

problem description

the child component does not have any click event to trigger, so the data needs to be loaded out. How can the parent component receive the values in the child component?

the environmental background of the problems and what methods you have tried

uses $children, no event triggers, and always gets a value of undefiend.

is there any good way to solve this problem?

Apr.05,2021

you can use ref to get the instance of the subcomponent, through which you can get all the values, and even call the methods of the subcomponent.


you can notify the child component with event this.$emit ('test', somedata) when the parent component invokes the child component < Child @ test= "test" / >
and then in the methods of your parent component,

test(somedata){
    //somedatasomedata
}

official usage of $emit

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