子组件 IMEComment
componentWillMount(){
this.props.onRef(this);
}
父组件
state = {
child:"",
}
onRef = (ref) => {
this.child = ref
}
<IMEComment onRef={this.onRef} ></IMEComment>
调用
this.child.commentAddClick
子组件 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
网友评论