重新路由到页面是一个问题,因为无法替换路由

时间:2019-04-21 19:26:36

标签: reactjs react-router react-router-dom

==>因此,我正在使用“ react-router-dom”,并已在以下路由中实现。

==>说我在“ http://localhost:3000/About”页面上,然后导航到“ http://localhost:3000/Articles/DevOps”。

==>现在,如果我再次想回到“关于”页面,我的网址将变成“ http://localhost:3000/Articles/About”,但是我希望它是“ http://localhost:3000/About”。

问:为什么这个'/ Articles / DevOps'整体没有被替换?

附上代码以供参考。谢谢

<Route  path="/About" component={AboutComponent} />
<Route  path="/Projects" component={ProjectsComponent} />
<Route  path="/IndustryExperience" component={IndustryExperienceComponent} />
<Route  path="/Contact" component={ContactComponent} />
<Route  path="/Resume" component={ResumeComponent} />
<Route  path="/" component={ResumeComponent} />

<Route exact path="/Articles/React" component={AboutComponent} />
<Route exact path="/Articles/DevOps" component={AboutComponent} />
<Route exact path="/Articles/Spring Boot" component={AboutComponent} />
<Route exact path="/Articles/CoreJava" component={AboutComponent} />
___________________________________________________________________________


<Nav.Link href="About">About</Nav.Link>
<Nav.Link href="Projects">Projects</Nav.Link>
<Nav.Link href="IndustryExperience">IndustryExperience</Nav.Link>
<Nav.Link href="Contact">Contact</Nav.Link>
<Nav.Link href="Resume">Resume</Nav.Link>
<NavDropdown title="Articles" id="collasible-nav-dropdown">
<NavDropdown.Item href="Articles/React">React</NavDropdown.Item>
<NavDropdown.Item href="Articles/DevOps">DevOps</NavDropdown.Item>
<NavDropdown.Item href="Articles/Spring Boot">Spring Boot</NavDropdown.Item>
<NavDropdown.Divider />
<NavDropdown.Item href="Articles/CoreJava">Core Java</NavDropdown.Item>
</NavDropdown>

0 个答案:

没有答案