我使用 react-router-dom
v6。 我希望我的 Login
页面上可以呈现不 Sidebar
和 Topbar
组成。 如何做到这一点?
function App() {
return (
<Router>
<Container>
<Sidebar />
<Content>
<Topbar />
<MainContent>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/users" element={<UserList />} />
<Route path="/users/:id" element={<User />} />
<Route path="/newUser" element={<NewUser />} />
<Route path="/products" element={<ProductList />} />
<Route path="/products/:id" element={<Product />} />
<Route path="/newProduct" element={<NewProduct />} />
<Route path="/login" element={<Login />} />
</Routes>
</MainContent>
</Content>
</Container>
</Router>
);
}
我不想让我登录网页呈现的内部 MainContent
但是把整个网页没有 Sidebar
和 Topbar
.
我试着移动 Routes
上已登录 route
上述栏但有一个错误 Error: [Sidebar] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>