我剛剛在我的應用程序中實現了基于路由器的代碼分割(延遲加載)。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'))
React 代碼拆分 - 在初始頁面后加載其他組件
翻翻過去那場雪
2023-08-18 17:11:31