初始化
初次加载组件的时候,会调用一次render函数
更新
- state发生改变
- props发生改变
强制更新
如果不是前两种,还希望组件发生更新,可以使用
this.forceUpdate()
注意:
<button onClick={() => this.forceUpdate()}>
强制渲染 不可以写为<button onClick={this.forceUpdate}>强制渲染</button>
初次加载组件的时候,会调用一次render函数
如果不是前两种,还希望组件发生更新,可以使用
this.forceUpdate()
注意:
<button onClick={() => this.forceUpdate()}>
强制渲染 不可以写为<button onClick={this.forceUpdate}>强制渲染</button>