在父组件里面:
{this.props.children && React.cloneElement(this.props.children, {
handleClick: this.handleClick,
})}
在子组件里面可以获取到:
handleClick = (props)=>{
this.props.handleClick(1,0);
}
在父组件里面:
{this.props.children && React.cloneElement(this.props.children, {
handleClick: this.handleClick,
})}
在子组件里面可以获取到:
handleClick = (props)=>{
this.props.handleClick(1,0);
}