lazy
const router = createBrowserRouter([
{
path: "/",
element: <App/>,
children: [
{path: '/', lazy: () => import( "@/pages/home")},
{path: "/about", lazy: () => import( "@/pages/about")},
{path: "/profile", lazy: () => import( "@/pages/profile")},
{path: "/*", element: "404页面"}
]
},
])export async function loader({request, context}: LoaderFunctionArgs) {
return {}
}
export async function action({request, context}: LoaderFunctionArgs) {
return {}
}
export const Component = () => {
return (
<div>
<h1>welcome</h1>
</div>
);
};
export const ErrorBoundary = () => {
return "组件渲染异常"
}单个文件中存放多个路由
最后更新于