简体   繁体   English

嵌套路由反应路由器4

[英]nested routes react router 4

when I click on a user image, the Id is changed in URL ("/r/:id") but page content remains the same. 当我点击用户图片时,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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM