你需要进行代码分割,在react中有以下几种方式 1.import() 使用之前 import { add } from './math'; console.log(add(16, 26)); 使用之后 import("./math").then(math => { console.log(math.add(16, 26)); }); 2.React.lazy 使用之前: import OtherComponent from './OtherComponent'; function MyComponent() { return ( <div> <OtherComponent /> </div> ); } 使用之后 const OtherComponent = React.lazy(() => import('./OtherComponent')); function MyComponent() { return ( <div> <OtherComponent /> </div> ); } 以上内容来自官方文档 这是官方原生(16.7)支持的,你也可以使用第三方组件 loadable-components react-loadable
你需要进行代码分割,在
react
中有以下几种方式1.import()
使用之前
使用之后
2.React.lazy
使用之前:
使用之后
以上内容来自官方文档
这是官方原生(16.7)支持的,你也可以使用第三方组件