【发布时间】:2020-08-08 03:25:57
【问题描述】:
当页面用 react-static 改变时,有没有办法滚动到顶部?我正在使用@reach/router,它默认包含在react-static中。
我已经试过了:
<Router onChange={window.scrollTo(0,0)}>
<Routes path="*"/>
</Router>
ans 这个(来自这个issue)
<Router history={history} autoScrollToTop={true}>
<Routes path="*"/>
</Router>
但两者都不起作用。
react-static 文档中提到了最后一个解决方案,但似乎已弃用,因为它不再在文档中。
【问题讨论】:
标签: javascript reactjs react-router react-static