react-异步组件

7/19/2020 react

# 异步组件



import React from 'react'
const ParentComponent = React.lazy(() => import('./Parent'))
class LazyDemoComponent extends React.Component {
    render(){
        return <div>
            <div>异步引入一个组件</div>
            <hr />
            <React.Suspense fallback={<div>loading...</div>}>
                <ParentComponent />
            </React.Suspense>
        </div>
    }
}
export const LazyDemo = LazyDemoComponent

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
更新: 7/29/2022, 4:33:42 PM