父组件
bindRef (ref) { this.child = ref } clickMethod = () => { this.child.childMethod() } render () { return ( <div className='wrapper'> <p onClick={this.clickMethod}>这是一个click事件</p> <child onRef={this.bindRef.bind(this)}></child> </div> ) }
子组件
childMethod () { console.log('我是子组件的方法') } componentDidMount () { this.props.onRef(this) }