react

Redirect的坑

2020-08-28  本文已影响0人  匆匆那年_海

之前在项目中路由的部分配置

<Route path='/login' component={Login} ></Route>
<Route path='/index' component={Home} ></Route>
{/* 重定向 */}
<Redirect from='/' to='/login' ></Redirect>

在已经登陆的的情况下手动输入http://localhost:3000/index想进入首页,可是实际会进入登录页面,因为http://localhost:3000/index含有/,所以就改用exact 精确匹配,<Route exact path='/' component={Login} ></Route>就完美解决了。

不对的地方还请各位大佬指点,小白谢谢大佬们

原文作者:匆匆那年_海,博客主页:https://www.jianshu.com/u/910c0667c515
95后前端汉子,爱编程、优秀、聪明、理性、沉稳、智慧的程序猿一枚。

上一篇 下一篇

猜你喜欢

热点阅读