react-bootstrap nav.link 路由 [英] react-bootstrap nav.link routing

查看:37
本文介绍了react-bootstrap nav.link 路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个项目.我有导航栏和 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?

*顺便说一句,原来是这样的其实我知道href是什么?所以,我删除了它并添加了to"

*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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆