首页 > 解决方案 > 反应路由器 - history.push 到页面的特定部分

问题描述

在 React 路由器中,我可以使用 history.push 更改页面,并且还可以转到新页面上的特定部分/锚点吗?例如:

 history.push('/home#section1');

在我的主页上,我有这个:

  <div class='back  backCard backCardFour ' id='section1'>
                    <div>
                        Then please don't hesitate to contact us, you can
                        use "Send us your thoughts that it's located on the
                        top of the page and ask us everything or give some
                        suggestions to improve our work
                    </div>
                </div>

标签: reactjsreact-router

解决方案


React Router 本身不支持锚点。

您可以为此使用React Router Hash Link 之类的东西。


推荐阅读