简体   繁体   English

如何从嵌套的React组件的“链接页面”的顶部开始?

[英]How to start at top of “linked page” with nested React components?

I have nested components using React and React Router. 我已经使用React和React Router嵌套了组件。 When I click onto a link that swaps out a component, I noticed that it doesn't bring me to the top of the page (for example, if I'm midway down the page, it'll place me there when the new component is loaded in). 当我单击交换出组件的链接时,我注意到它没有将我带到页面顶部(例如,如果我位于页面中间,则当我将新组件放置在页面中时,它将放置在此处)已加载)。 What's the best way to link to the top of the "next page" (or have it jump there, rather any type of visible scroll when loaded)? 链接到“下一页”顶部的最佳方法是什么(或使其跳到那里,而不是加载时可见的滚动条)? Ideally, with anchor tags or vanilla Javascript (no jQuery). 理想情况下,使用锚标签或原始Javascript(无jQuery)。 Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM