我刚刚在我的应用程序中实现了基于路由器的代码分割(延迟加载)。AFAIK,当实现延迟加载时,访问页面的用户将仅加载整个包的某个块,而不会加载其他内容。
那么,有没有一种方法可以让React在初始页面加载后开始加载其他组件,这样用户跳转到另一个页面时就不必等待呢?
const App = React.lazy(() => import('./components/home/App'))
const Game = React.lazy(() => import('./components/game/Game'))
const Custom = React.lazy(() => import('./components/custom/Custom'))
const Credits = React.lazy(() => import('./components/credits/Credits'))
const Rules = React.lazy(() => import('./components/rules/Rules'))
const NotFound = React.lazy(() => import('./components/404/404'))
侃侃无极
相关分类