React 入门笔记

生命周期的相关概念

  1. willMount //即将挂载Dom
  2. didMount //已经挂载dom
  3. willReciveProps //即将接受参数
  4. shouldComponentUpdate // 是否需要更新component, return true or false
  5. willUpdate //即将更新dom
  6. didUpdate //已经更新dom

方法需要bind(this)

<button onClick={this.handleClick.bind(this)}>点击一下</button>
 handleClick() {
    this.setState({
      count: this.state.count + 1
    })
  }

猜你喜欢

转载自blog.csdn.net/weixin_40814356/article/details/84601798