页面切换时滚动条没有返回到顶部

This commit is contained in:
caishi 2021-07-12 17:00:40 +08:00
parent 0566d32268
commit 1e3ce12d93
2 changed files with 9 additions and 2 deletions

View File

@ -89,7 +89,7 @@ class App extends Component {
mygetHelmetapi: null,
}
}
HideAddcoursestypess = (i) => {
this.setState({
Addcoursestype: false,
@ -108,7 +108,6 @@ class App extends Component {
document.title = "loading...";
initAxiosInterceptors(this.props);
this.getAppdata();
window.addEventListener('error', (event) => {
const msg = `${event.type}: ${event.message}`;
});

View File

@ -27,6 +27,14 @@ const ProjectDetail = Loadable({
});
class Index extends Component {
componentDidUpdate=(preProps)=>{
this.props.history.listen(()=>{
if (document.body.scrollTop || document.documentElement.scrollTop > 0) {
window.scrollTo(0, 0);
}
})
}
render() {
return (
<div className="newMain clearfix">