【发布时间】:2019-04-16 08:35:40
【问题描述】:
如何检查递归路径是否在react router中,这个
import { Switch, Route, Redirect } from 'react-router-dom';
<Switch>
<Route exact path="/" component={SignIn} />
<Route path="/signup" component={SignUp} />
<Route path="/forget-password" component={ForgetPasswordPage} />
<Route path="/reset-password" component={ResetPasswordPage} />
<Route component={PageNotFound} />
</Switch>
如果我在我的浏览器中输入错误的网址 (http://0.0.0.0:3000/dgdfg),它会将我带到 PageNotFound
但是,如果我给(http://0.0.0.0:3000/signup/dgdfg)它不会带我去PageNotFound 组件,它会向我显示空白页。如何使用 react router v4 解决这个问题
【问题讨论】:
-
如果你使用
exact path=而不是path会怎样?
标签: reactjs react-router react-router-dom