react-bootstrap nav.link 路由 [英] react-bootstrap nav.link routing
问题描述
我正在做一个项目.我有导航栏和 nav.links.例如房屋、价格和功能.
I am working on a project. I have navbar and nav.links on it. such as home, price and features.
我想在单击它时进行页面路由.这是我的代码.我做了通常的路由风格,但它不起作用.
I would like to page routing when I click it. Here is my codes about it. I did it usual routing style but it doesn't work.
<LinkContainer>
<Nav.Link to="/price" >Price</Nav.Link>
</LinkContainer>
以及我在 app.js 中的路由定义;
and my routing definations in app.js;
<Route path ="/price" exact component={Price}></Route>
我创建并导入 price.js 并导入它们.
I create and import price.js and also import them.
我可以成功地在我的按钮上使用路由,但 nav.links 不起作用.任何想法?
I can succesfully use routing on my buttons but nav.links doesn't work. Any idea?
*顺便说一句,原来是这样的
*Btw it was orginally like this <Nav.Link href="#price" >Price</Nav.Link>
Actually idk what is href for?So, I erased it and add "to"
推荐答案
这段代码对我有用:
这篇关于react-bootstrap nav.link 路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!