首页 > 解决方案 > 如何通过history.push in react移动到顶部

问题描述

我使用 history.push 但这显示中间或底部或顶部或下一页的内容。

我想每次都把那个节目放在下一页的顶部。

请给我建议。

标签: reactjsreact-router

解决方案


您应该window.scrollTo(0, 0);在 componentDidMount 中使用。


推荐阅读