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

Pass parent component to child component: props

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

One 、 Communication between parent components is very common in development , For example, the parent component has some data , Sub components are required for presentation ;

  • At this time we can adopt props To complete the communication between components ;

Two 、 What is? Props Well ?

  • Props Yes, you can on the component Register some custom attribute;
  • Parent component to these attribute assignment , Subcomponent pass attribute Get the corresponding value from the name of ;

3、 ... and 、Props There are two common uses :

  • Mode one Array of strings , The string in the array is attribute The name of ;
  • Mode two object type , The object type can be specified in attribute Name at the same time , Specify the type it passes , Is it necessary 、 Default value and so on ;

Mode one : Dynamic data should be colon

  Mode two :

原网站

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