Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用库iframe-resizer。所以,我创建了 react - 组件。当我等待在框架中加载内容时,我想在这段时间内显示用户圆条。如何理解加载完成?
你需要经历 React.js 的生命周期
有两种生命周期方法
componentWillMount() - 在加载 DOM 之前被调用。 componentDidMount() - 在 DOM 加载/组件完全渲染后调用。
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