Scroll behaviour in vue router not working firefox


i am facing a issue with scroll behavior which not working in firefox. But for firefox i am using alternative method to move to the position on top if user navigating from the top of any page.

Its working fine in chrome, edge but except firefox.
scrollBehavior (to, from, savedPosition) {

  if (savedPosition) {

    return savedPosition

  } else {

    return { x: 0, y: 0 }



  routes: routes


my alternative method is mention below. I dont want to use this.

mounted() {

            setTimeout(() => {

            document.body.scrollTop = document.documentElement.scrollTop = 0;

            }, 500);