生命周期的相关概念
- willMount //即将挂载Dom
- didMount //已经挂载dom
- willReciveProps //即将接受参数
- shouldComponentUpdate // 是否需要更新component, return true or false
- willUpdate //即将更新dom
- didUpdate //已经更新dom
方法需要bind(this)
<button onClick={this.handleClick.bind(this)}>点击一下</button>
handleClick() {
this.setState({
count: this.state.count + 1
})
}