In a single-page application in react, when the mobile end moves from page A to page B, the initial position of page B is the location of page A. How can we make the scrollTop of B page 0?

For a single-page application in

react, when the mobile end moves from page A to page B, the initial position of page B is the location of page A. How can I make the scrollTop of B page 0

Mar.04,2021

of course, enforce

on the b page.
componentWillMount(){
    document.documentElement.scrollTop = 0;
}

but basically you should check to see if there is something wrong with the route you wrote.

Menu