React 父组件调用子组件方法
2018-09-13 本文已影响0人
_嘿嘿_
子组件 IMEComment
componentWillMount(){
this.props.onRef(this);
}
父组件
state = {
child:"",
}
onRef = (ref) => {
this.child = ref
}
<IMEComment onRef={this.onRef} ></IMEComment>
调用
this.child.commentAddClick