1
10
在解决OP问题时,这里的首要答案可能不是大多数人想要的解决方案,因为它关闭了Reach路由器最重要的可访问性功能。
事实上,Reach router将重点放在匹配的内容上
是
A.
背景
那么,背景呢
但尽管如此,还是有解决办法的。如果使用手动滚动到页面顶部
当然,这是一个有点黑客和必要的解决办法,但我认为这是最好的(也许是唯一的)解决方案,这个问题不破坏可访问性。
|
2
15
试用
https://reach.tech/router/api/Router
:如果您担心破坏可访问性,请参阅以下答案: https://stackoverflow.com/a/56996986/428780 |
3
4
在@Marcus answer的基础上,你可以用
|
4
3
我必须综合运用各种方法才能使它发挥作用。即使设置
React Router's scroll restoration guide .
|
5
0
|
6
0
使用
请注意,在React路由器中,您可以使用
|
7
0
我用它制作了一个npm包,以简化集成: https://www.npmjs.com/package/reach-router-scroll-top |