React 子组件给父组件传值,父组件接收

第一步 绑定事件

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

第二部向父组件传递

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

第三部 父组件接收

<Search getFun={
    
    this.handClickChilder}/>

第四部获取值

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

结果
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_45103130/article/details/127552387