forked from Gitlink/forgeplus-react
组件之间进行页面跳转时,滚动条未返回至顶部
This commit is contained in:
parent
b70dd5928e
commit
6a6f0ca784
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "forge",
|
||||
"version": "0.1.0",
|
||||
"version": "3.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -2065,7 +2065,7 @@
|
|||
},
|
||||
"babel-polyfill": {
|
||||
"version": "6.26.0",
|
||||
"resolved": "https://registry.npm.taobao.org/babel-polyfill/download/babel-polyfill-6.26.0.tgz",
|
||||
"resolved": "https://registry.nlark.com/babel-polyfill/download/babel-polyfill-6.26.0.tgz",
|
||||
"integrity": "sha1-N5k3q8Z9eJWXCtxiHyhM2WbPIVM=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
|
|
@ -124,12 +124,6 @@ class App extends Component {
|
|||
componentDidMount() {
|
||||
document.title = "loading...";
|
||||
this.disableVideoContextMenu();
|
||||
history.listen(() => {
|
||||
this.forceUpdate()
|
||||
const $ = window.$
|
||||
$("html").animate({ scrollTop: $('html').scrollTop() - 0 })
|
||||
});
|
||||
|
||||
initAxiosInterceptors(this.props);
|
||||
this.getAppdata();
|
||||
|
||||
|
|
|
@ -31,6 +31,14 @@ const Infos = Loadable({
|
|||
loading: Loading,
|
||||
});
|
||||
class Index extends Component {
|
||||
|
||||
componentDidUpdate=()=>{
|
||||
this.props.history.listen(()=>{
|
||||
if (document.body.scrollTop || document.documentElement.scrollTop > 0) {
|
||||
window.scrollTo(0, 0)
|
||||
}
|
||||
})
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<div className="newMain clearfix">
|
||||
|
|
|
@ -67,6 +67,11 @@ class Infos extends Component {
|
|||
if(prevUser && username && prevUser !== username){
|
||||
this.fetchUser();
|
||||
}
|
||||
this.props.history.listen(()=>{
|
||||
if (document.body.scrollTop || document.documentElement.scrollTop > 0) {
|
||||
window.scrollTo(0, 0)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fetchUser = () => {
|
||||
|
|
|
@ -13,6 +13,7 @@ configureUrlQuery({ history });
|
|||
window.__useKindEditor = false;
|
||||
|
||||
|
||||
|
||||
const render = (Component) => {
|
||||
ReactDOM.render(
|
||||
<AppContainer >
|
||||
|
|
Loading…
Reference in New Issue