1、子组件调用父组件方法
父组件html
<div>
<Chlid link={this.fn()} />
</div>
父组件js
fn= e => {
console.log(e) //123
};
子组件html
<div onClick={() => {
this.props.link(123);
}}>点击事件</div>
<div>
<Chlid link={(e) => {
this.child = e;
}}
/></div>
<div onClick={() => {
this.child.fn(123);
}}>点击事件</div>
componentDidMount(){
this.props.link(this)
}
fn= (e) => {
console.log(e);
};