reactjs - 反应路由器 - 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>
解决方案
React Router 本身不支持锚点。
您可以为此使用React Router Hash Link 之类的东西。
推荐阅读
- regex - 正则表达式仅在某些字符内时匹配组
- c# - 将“SELECT TOP (1) WITH TIES”转换为 EF Core
- php - Apache2 PHP - 如何使用 .htaccess 重写直接下载链接
- node.js - 使用 Node.js 模块 nfc-pcsc 编写后,NFC Tag 的扇区不再工作
- javascript - 有没有办法在异步函数上实现上下文?
- python - 循环中的 Tkinter python 3.8 组合框。附加到列表时如何纠正错误的选择?
- c# - 压缩文件时可以维护目录结构吗?
- oracle - Oracle 侦听器(如何添加 XE SID)?
- r - R在终端中一次运行多个脚本
- python - 尝试在 Python 的 groupby 函数中使用 Lambda 对大于 x 的项目求和