我发现了一个错误:
Warning: A path must be pathname + search + hash only, not a full URL like "http://www.shadyab.com/category/tehran/fast_food" <li className="hidden-xs hvr-shutter-out-vertical">
<Link to={serverConstants.DOMAIN_URL + 'category/tehran/fast_food'} >فست فود</Link>
</li>我的常数文件。
export const serverConstants = {
DOMAIN_URL: "http://www.shadyab.com/",
}如果删除serverConstants.DOMAIN_URL,则将我的url追加到当前url。
例如:
当前网址:
http://localhost:3000/category/tehran/foreign_restaurant现在,如果我点击下面的链接:
<Link to={'category/tehran/fast_food'} >فست فود</Link>我的网址看起来是这样的:
http://localhost:3000/category/tehran/category/tehran/fast_food我的路线:
<Route path="/category/:city/:category" component={Category} />我的反应路由器版本:
"react-router": "^3.0.5",发布于 2018-05-06 10:40:58
使用Link,您不需要指定域名,只需指定路由路径,如
<li className="hidden-xs hvr-shutter-out-vertical">
<Link to={'/category/tehran/fast_food'} >فست فود</Link>
</li>https://stackoverflow.com/questions/50198315
复制相似问题