简体   繁体   English

在同一页面上反应路由

[英]React routing on the same page

I am new to React, and I trying to make a website that has only one page with multiple section.我是 React 新手,我试图制作一个只有一个页面和多个部分的网站。 How can I make a navigation bar to send me when I click, for example, on contact link to contact section that is lower in the page.例如,当我单击页面下方的联系部分的联系链接时,如何制作导航栏以发送给我。 Or when I click 'Services' to go upper in the page(exemple).或者当我点击页面上方的 go 的“服务”时(示例)。 I don't want code snippets, I just want a starting point.我不想要代码片段,我只想要一个起点。 About what shoul I read?我应该读什么? I am looking for this thing for a couple of hours but I can't find anything.我正在寻找这个东西几个小时,但我找不到任何东西。

You can use您可以使用

<a href="#id">

where id is the id of the tag you want to go.其中 id 是您想要 go 的标签的 id。 For example, you have a div例如,你有一个 div

<div id="section1"> 

and another div和另一个 div

<div id="section2"> 

you can create two anchor in your navigation bar您可以在导航栏中创建两个锚点

<a href="#section1"> <a href="#section2"> 

which when clicked scrolls the page to the corresponding section.单击时将页面滚动到相应的部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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