reactrouter路由重定向⽂档
⽰例
const {
HashRouter,
Route,
Switch,
Redirect,
} = window.ReactRouterDOM
return (
<HashRouter>
<Switch>
<Route exact path="/">
{`<Home />`}
</Route>
<Route path="/old-match"> {/* 重定向 */}
<Redirect to="/will-match" />
</Route>
<Route path="/will-match">
{`<WillMatch />`}
</Route>
<Route path="*"> {/* 404 */}
{`<NoMatch />`}
</Route>
react router拦截</Switch>
</HashRouter>
)
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论