简体   繁体   中英

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.

<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} />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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