From 3fb9ef93aadd531ff6e4a2bf99dc676383ad1583 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Wed, 25 Jul 2018 02:03:00 +0800 Subject: [PATCH] Modify theme scroll to top. --- theme/default/layout/BasicLayout.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/theme/default/layout/BasicLayout.js b/theme/default/layout/BasicLayout.js index a58aff2..e110145 100644 --- a/theme/default/layout/BasicLayout.js +++ b/theme/default/layout/BasicLayout.js @@ -21,6 +21,17 @@ export default class BasicLayout extends PureComponent { super(props); this.state = {}; } + componentDidUpdate() { + this.scrollToTop(); + } + componentDidMount() { + this.scrollToTop(); + } + scrollToTop() { + document.body.scrollTop = 0; + document.documentElement.scrollTop = 0; + window.scrollTo(0, 0); + } renderSubMenuItem(menus) { const { location: { pathname } } = this.props; if (menus.length > 1) {