From f50c9b46f75b1250514e7b5b13940d57235af5db Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Wed, 13 May 2020 17:10:36 +0300 Subject: [PATCH] Use a custom hook to reset scroll before each route unlike scrollbehavior --- src/main.js | 5 +++++ src/router.js | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main.js b/src/main.js index 74721f03a..1ee95933d 100644 --- a/src/main.js +++ b/src/main.js @@ -162,6 +162,11 @@ Vue.component('Galleria', Galleria); Vue.component('CodeHighlight', CodeHighlight); +router.beforeEach(function (to, from, next) { + window.scrollTo(0, 0); + next(); +}); + new Vue({ router, render: h => h(App) diff --git a/src/router.js b/src/router.js index d794dabf6..7386d41e7 100755 --- a/src/router.js +++ b/src/router.js @@ -675,8 +675,5 @@ export default new Router({ name: 'galleriacaption', component: () => import('./views/galleria/GalleriaCaptionDemo.vue') } - ], - scrollBehavior() { - return {x: 0, y: 0}; - } + ] });