我的App.js中有以下几条路线:
<Router history={history}>
<div>
<Switch>
<Route path='/login' component={LoginPage} />
<Route path='/administrate' component={AdministratePage} />
</Switch>
</div>
</Router>在默认/Index.cshtml视图中引用了我的bundle.js:
<div id="root" />
<script src="~/Scripts/react/dist/bundle.js"></script>成功登录后,我执行:
this.props.history.push('/administrate');..。在我的LoginPage组件中,它成功地重定向到/administrate
问题:如何防止在点击管理页面上的F5时被重定向到登录页面?
谢谢。
发布于 2018-04-10 12:57:24
在页面重新加载内存中的所有信息之后,为了保持日志记录,您需要在登录后保存用户会话数据,并在初始页面加载时检查它。
最简单的方法可以是cookies或localStorage。
https://stackoverflow.com/questions/49753883
复制相似问题