mirror of
https://github.com/PlayEdu/frontend.git
synced 2025-06-08 06:30:41 +08:00
路由懒加载 + loading
This commit is contained in:
parent
a0a6744404
commit
a5a57c1b99
@ -1,14 +1,16 @@
|
||||
import { useRoutes } from "react-router-dom";
|
||||
import routes from "./routes";
|
||||
import "./App.scss";
|
||||
import { Suspense } from "react";
|
||||
import LoadingPage from "./pages/loading";
|
||||
|
||||
function App() {
|
||||
const Views = () => useRoutes(routes);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Suspense fallback={<LoadingPage />}>
|
||||
<Views />
|
||||
</div>
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
|
||||
|
11
src/pages/loading/index.tsx
Normal file
11
src/pages/loading/index.tsx
Normal file
@ -0,0 +1,11 @@
|
||||
import { Spin } from "antd";
|
||||
|
||||
const LoadingPage = () => {
|
||||
return (
|
||||
<>
|
||||
<Spin />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default LoadingPage;
|
@ -3,6 +3,7 @@ import { RouteObject } from "react-router-dom";
|
||||
|
||||
import { LayoutPage } from "../pages";
|
||||
|
||||
// 懒加载
|
||||
const LoginPage = lazy(() => import('../pages/login'))
|
||||
|
||||
const routes: RouteObject[] = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user