1

我目前有以下惰性组件导入:

const LazyDashboard = React.lazy(() => import('./pages/app/Dashboard'));
const LazyProfile = React.lazy(() => import('./pages/app/Profile'));

然后在路线上,

{userToken && <><Route exact path="/app" element={<LazyDashboard/>}/> 
                <Route exact path="/app" element={<LazyProfile/>}/></>}
  • 转到仪表板,加载了一个块。好!
  • 转到配置文件,加载了另一个块..不好!如何将这两个导入标记为捆绑在同一个块中?

有没有办法用 React.lazy 做到这一点?

4

0 回答 0