0

我使用库iframe-resizer。所以,我创建了 react - 组件。当我等待在框架中加载内容时,我想在这段时间内显示用户圆条。如何理解加载完成?

4

1 回答 1

0

你需要经历 React.js 的生命周期

有两种生命周期方法

componentWillMount() - 在加载 DOM 之前被调用。

componentDidMount() - 在 DOM 加载/组件完全渲染后调用。

所以你也是

componentWillMount(){
 //show MyLoader
}

componentDidMount(){
  // hide MyLoader
}

查看更多 - https://developmentarc.gitbooks.io/react-indepth/content/life_cycle/birth/premounting_with_componentwillmount.html

https://developmentarc.gitbooks.io/react-indepth/content/life_cycle/birth/post_mount_with_component_did_mount.html

于 2018-05-30T11:32:48.367 回答