react生命周期

69 阅读1分钟

componentDidMount:装载完成,在render()函数之后调用 componentDidUpdate:更新数据 componentWillUnmount:卸载

一般数据获取或者数据处理都放在componentDidMount里面调用,因为只有组件完全挂载到网页上,获取的数据才能加载到组件上面。

setState方法可以触发重渲染