react父组件获取子组件的值或方法
时间:2019-12-10 19:15:04
收藏:0
阅读:1047
父组件:
<Child onRef={(ref) => { this.child = ref; }} />
用的时候直接从this.child里面取
子组件:
componentDidMount() {
this.props.onRef(this);
}
原文:https://www.cnblogs.com/hamili/p/12017962.html
评论(0)