react父组件获取子组件的值或方法

父组件:

  <Child onRef={(ref) => { this.child = ref; }} />

  用的时候直接从this.child里面取

子组件:

  componentDidMount() {
      this.props.onRef(this);
     }
原文地址:https://www.cnblogs.com/hamili/p/12017962.html