美文网首页
React 父组件调用子组件方法

React 父组件调用子组件方法

作者: _嘿嘿_ | 来源:发表于2018-09-13 16:36 被阅读0次

    子组件 IMEComment
    componentWillMount(){
    this.props.onRef(this);
    }

    父组件
    state = {
    child:"",

    }
    

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

    调用
    this.child.commentAddClick

    相关文章

      网友评论

          本文标题:React 父组件调用子组件方法

          本文链接:https://www.haomeiwen.com/subject/rqtggftx.html