父组件:
<Child onRef={(ref) => { this.child = ref; }} />
用的时候直接从this.child里面取
子组件:
componentDidMount() {
this.props.onRef(this);
}
父组件:
<Child onRef={(ref) => { this.child = ref; }} />
用的时候直接从this.child里面取
子组件: