嵌套路由反应路由器4

时间:2019-06-10 15:19:04

标签: javascript html reactjs

当我单击用户图像时,URL中的ID更改了(“ / 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>

1 个答案:

答案 0 :(得分:0)

尝试使用此代替:

<!DOCTYPE HTML>
<html>

<head>
  <link href="https://fonts.googleapis.com/css?family=Lora:400,700|Montserrat:300" rel="stylesheet">

</head>

<body>

  <div class="removable_item_container">
    <div class="removable_item_text">Removable item</div>
    <div class="removable_item_remove">x</div>
  </div>

  <script>
  </script>
</body>

</html>