当前位置:网站首页>Communication of components

Communication of components

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

When I was writing the explanation of component nesting :

App When the component headers Parent component of component ; 

One 、 In the development process , We often encounter communication between components :

  • such as App Many may be used Header, Everywhere Header The content displayed is different , Then we need User delivery Header Some of the data , Let it show ;
  • Another example is that we are in Main Once in a while Request the Banner Data and ProductList data , Then you need to pass it on to them for display
  • It could be An event occurred in the subcomponent , need Some operations are done by the parent component , It needs to The child component passes events to the parent component ;

Two 、 Communication between parent and child components

  • Pass parent component to child component : adopt props attribute ;
  • The child component is passed to the parent component : adopt $emit Triggering event ;
原网站

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