gpt4 book ai didi

react-router - 在 react 路由器中重定向未定义?

转载 作者:行者123 更新时间:2023-12-04 22:18:55 25 4
gpt4 key购买 nike

这就是我的 react 路由器代码的样子

render((
<Router history={browserHistory}>
<Route path={CORP} component={App}>
<IndexRoute component={Home} />
<Route path={"outreach"} component={OutReach}/>
<Route path={"careers/m"} component={Career}/>
<Route path={"members"} component={Members}/>
<Redirect from="*" to={"/home"} />
</Route>
</Router>
), document.getElementById('app'))

但是当我转到我的页面时,我的控制台中出现此错误

Uncaught ReferenceError: Redirect is not defined



我如何告诉 react-router 将用户重定向到 /home仅当用户的目的地与上述任何路线路径不匹配时?

最佳答案

你只需要添加

import { Redirect } from 'react-router';

在您的文件顶部

关于react-router - 在 react 路由器中重定向未定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43896511/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com