【问题标题】:How to Jump to particular section using React router-dom Link如何使用 React router-dom Link 跳转到特定部分
【发布时间】:2021-08-18 11:48:38
【问题描述】:

<Link to="/greetings#section2"/>
当我们在 react dom 中使用 Link 时,它会跳转到问候页面,但它不能跳转到特定部分,因为
<a href="/greetings#section2"/> 有没有人知道如何使用 LINK 这样做

【问题讨论】:

标签: reactjs hyperlink anchor react-router-dom


【解决方案1】:

您可以使用to props 解决它:

<Link to={{pathname: '/greetings', hash: '#section2'}} />

但我的问题是,为什么你害怕在这种情况下使用 &lt;a&gt; 标签?

【讨论】:

猜你喜欢
  • 2015-04-19
  • 1970-01-01
  • 2021-05-07
  • 1970-01-01
  • 2019-11-25
  • 2020-04-24
  • 1970-01-01
  • 2023-03-06
  • 2021-01-28
相关资源
最近更新 更多