Skip to content
字数
76 字
阅读时间
1 分钟

https://stackblitz.com/github/remix-run/react-router/tree/main/examples/lazy-loading?file=src%2FApp.tsx

js

const About = React.lazy( ()=>import('./pages/About'));
const Dashboard = React.lazy(() => import("./pages/Dashboard"));


<Routes>
	<Route path="/" element={<Layout />}>
	  <Route index element={<Home />} />
	  <Route
		path="about"
		element={
		  <React.Suspense fallback={<>...</>}>
			<About />
		  </React.Suspense>
		}
	  />
	  <Route
		path="dashboard/*"
		element={
		  <React.Suspense fallback={<>...</>}>
			<Dashboard />
		  </React.Suspense>
		}
	  />
	  <Route path="*" element={<NoMatch />} />
	</Route>
</Routes>

贡献者

The avatar of contributor named as rover rover

页面历史

Power by nolebase