class Father extends Component {

    construtor(props){
        super(props);
        this.state={
            name: 'Peter',
            age: '26'
        }
    }
    onChangeState(stateName){
        this.setState(stateName)
    }
    render(){
        <p>姓名:{this.state.name}</p>
        <p>年龄:{this.state.age}</p>
        <Child onClicked={this.onChangeState.bind(this)}/>
    }
}
 
 
 
class Child extends Component {
    render(){
        <Button onClicked={()=>this.props.onClicked({name: 'John'})}/>
    }
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-30
  • 2022-12-23
  • 2021-08-13
  • 2021-10-23
  • 2022-03-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案