1、新增路由配置檔案 routes.js
import { lazy } from "react"; export default [ { path:'/admin', component:lazy(()=>import('./App.js')), }, ]
2、App.js 中使用路由
import routes from './routes.js'; import { BrowserRouter } from "react-router-dom"; import { renderRoutes } from "react-router-config"; const App =()=>{ return <BrowserRouter>{renderRoutes(routes)}</BrowserRouter> } export default App;