父组件
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 onClick={()=>this.props.onClicked({name: 'John'})}/> } }