我正在尝试拆分我的捆绑包,以便仅加载出于更好性能目的所需的捆绑包,而我尝试了以下操作:
const Registration = lazy(() => import('./modules/Registration/Components/Registration'))
function App() {
const { state } = useContext(GlobalStore)
return (
<ApolloProvider client={apolloClient}>
<Router>
<Wrapper>
<Header />
<Page>
<Suspense fallback={<div>Loading component...</div>}>
<Switch>
<Route path="/" exact>
<Registration />
</Route>
<Route>
<PageNotFound />
</Route>
<Route path="/not-authorized" exact></Route>
</Switch>
</Suspense>
</Page>
<Footer />
</Wrapper>
</Router>
</ApolloProvider>
)
}
由于某种原因,这无法正常显示错误:
TypeError:无法获取动态导入的模块:http://localhost:3000/static/js/modules/Registration/Components/Registration