当前位置:网站首页>Pass child component to parent component

Pass child component to parent component

2022-07-07 07:09:00 To be a woman of light

1. What kind of situation does the sub component Zu Yao deliver content to the sub component ?

  • When Some events occur in the subcomponent When , For example, a click occurs in a component , Parent component needs to switch content ;
  • Child components There is something you want to pass to the parent component When ;

How do we complete the above operation ?

  1. First , We need to be in The name of the event to be triggered in some cases is defined in the sub component ;
  2. secondly , stay In parent component v-on Pass in the event name to listen , And bound to the corresponding method
  3. Last , When an event occurs in a subcomponent , Trigger the corresponding event according to the event name ;

Small cases :

  When delivering events , You can also pass a parameter .

Receive and process this parameter :

原网站

版权声明
本文为[To be a woman of light]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207070312311839.html