React child components pass values to parent components, and parent components receive

The first step is to bind the event

<Button type="primary" onClick={
    
    this.handClickSeach}>查询</Button>

The second part is passed to the parent component

handClickSeach =()=>{
    
    
    let data=[{
    
    id:'1'}]
    this.props.getFun(data); 
  };

The third part parent component receives

<Search getFun={
    
    this.handClickChilder}/>

The fourth part gets the value

handClickChilder=(data)=>{
    
    
    console.log(data,'接收子组件传来的值')
}

result
insert image description here

Guess you like

Origin blog.csdn.net/weixin_45103130/article/details/127552387