父组件:

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

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

子组件:

  componentDidMount() {
      this.props.onRef(this);
     }

相关文章:

  • 2022-03-04
  • 2022-12-23
  • 2022-12-23
  • 2021-10-23
  • 2022-03-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-05
  • 2022-12-23
  • 2021-07-21
  • 2022-12-23
  • 2022-12-23
  • 2021-04-09
  • 2021-09-15
相关资源
相似解决方案