[英]React router: Route not working
我在URL为
http://localhost:3000/dashboard/profile/timeline/abcd
并将路线设置为
<Route path="/dashboard/profile/:screenId/:userId" component={this.Routing}/>
当我去不同的个人资料例如
http://localhost:3000/dashboard/profile/timeline/xyz
它没有路由,但网址正在更改
任何建议都会有帮助
用component={this.Routing}
替换component={this.Routing}
component={Routing}
<Route exact path="/dashboard/profile/:screenId/:userId" component={Routing}/>
React:<Route精确路径=“ /” />和<Route path =“ /” />之间的区别
如果您的问题不能解决,请使用Switch
我也有这个问题,我可以通过Switch
解决
import {BrowserRouter, Route, Switch} from "react-router-dom";
.
.
.
.
<BrowserRouter>
<Switch>
<Route exact key="1" path="/dashboard/profile/:screenId/:userId" component={Routing}/>
</Switch>
</BrowserRouter>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.