[英]nested routes react router 4
當我點擊用戶圖片時,ID在URL(“/ r /:id”)中更改,但頁面內容保持不變。
<BrowserRouter>
<Switch>
<Route path="/r/:id" component={View} />
</Switch>
</BrowserRouter>,
<Link
to={{
pathname: `/r/${item.uid}`,
state: item,
}}
>
<div className="video-overlay" >
<div className="imagepop" >
<div className="box-imag" >
<img
alt="#"
className="img-responsive img-over"
src={(item.cover) || two}
/>
</div>
</div>
</div>
</Link>
請嘗試使用此代碼:
<Route exact path="/r/:id" component={View} />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.