应用程序.js
class App extends Component {
render() {
return (
<Router history={history}>
<Switch>
<Route path="/" exact component={Login} />
<div>
<Header />
<div className="main">
<SideBar />
<Route
path="/dashboard"
exact
component={RequireAuth(Dashboard)}
/>
<Route path="/profile" exact component={RequireAuth(Profile)} />
</div>
</div>
</Switch>
</Router>
);
}
}
在这里,我希望标题和侧边栏在我更改路线时在所有页面中通用,并且我得到了结果,但我认为这不是这样做的标准方法,请建议并帮助我,我应该如何创建通用某些页面的布局和其他页面的另一种布局,例如
<Router history={history}>
<Switch>
<layout1>
<Route path="/dashboard" exact component={RequireAuth(Dashboard)}/>
<Route path="/profile" exact component={RequireAuth(Profile)} />
</layout1>
<layout2>
<Route path="/otherinfo1" exact component={RequireAuth(OtherInfo1)}/>
<Route path="/otherinfo2" exact component={RequireAuth(OtherInfo2)} />
</layout2>
</Switch>
</Router>
我正在使用react-router 4.2.2
每次我登录并重定向到仪表板时,jquery 功能都不起作用,我总是需要刷新页面以运行 jquery 相关的东西(如果有帮助)