1
我有兩種佈局:登錄和註冊組件的MainLayout
和EmptyLayout
。React路由器V4結構
這是我目前的結構:
import { BrowserRouter as Router, Route } from 'react-router-dom';
const App =() => (
<Router>
<Switch>
<Route exact path="/login">
<EmptyLayout>
<LogInContainer />
</EmptyLayout>
</Route>
<Route path="/">
<MainLayout>
<Switch>
<Route exact path="/marketing" >
<MarketingComponent />
</Route>
<Route exact path="/dashboard" >
<DashboardContainer />
</Route>
<Route exact path="/admin/users" >
<UsersContainer />
</Route>
<Route exact path="/admin/users/add" >
<AddUsersContainer />
</Route>
</Switch>
</MainLayout>
</Route>
</Switch>
</Router>
);
這是一個好辦法? 如何在這裏包含404頁面?
<EmptyLayout>
<NotFound />
</EmptyLayout>