function App() {
return (
<Routes>
{routes.map((route) => (
<Route
exact
key={route.path}
path={route.path}
element={<route.component />}
/>
))}
</Routes>
);
}
进行路由配置,主页显示空白,在网页中F12检查报错显示Error: useRoutes() may be used only in the context of a <Router> component
app.jsx改正后代码
function App() {
return (
<Router>
<Routes>
{routes.map((route) => (
<Route
exact
key={route.path}
path={route.path}
element={<route.component />}
/>
))}
</Routes>
</Router>
);
}