Vue child component passes value to parent component

 

Keywords: $on $emit 

<LoginForID v-on:listentoID="getUserID" v-on:listentoPSW="getUserPsw" v-if="which_to_show == 'LoginForID'"></LoginForID>

 

getUserID and getUserPsw are the methods defined by the methods in the parent component to obtain the data of the child component

 

 

The child component needs to monitor the change of the input input value through the change event , trigger the event to notify the parent component and pass the data of the child component as a parameter to the parent component

 

There are two methods defined by the parent component to get the parameters passed by the child component:

 

data is the parameter passed from the child component, which is directly copied to the local attribute of the parent component to complete the value transfer

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325814828&siteId=291194637