父组件向子组件传输用prop,那如果子组件向父组件传输怎么传呢子组件通过click事件点击,把回调里面的flag变量里面值想传给父组件,怎么传呢classChild_1extendsReact.Component{//子组件constructor(props){super(props);this.state={getName:this.props.name,getAge:this.props.age,}}click=()=>{letflag='test';}render(){const{getName,getAge}=this.state;return({`姓名:${getName}`}
{`年龄:${getAge}`}
clickme
)}}exportdefaultChild_1;importChild_1from'./Child_1';classParentextendsReact.Component{//父组件constructor(props){super(props);this.state={}}componentDidMount(){}render(){return()}}exportdefaultParent;
哈士奇WWW