Vue router not scrolling when i set hash property

Viewed 164
const router = new VueRouter ({
  mode: 'history',
  routes,
  scrollBehavior(to,from, savedPosition) {
    if(to.hash) {
      return {
        selector: to.hash,
        behavior: "smooth"
      }
    }

    console.log(from, savedPosition)
    console.log(to)
  }
});

In my Home component :
<router-link :to="{path: '/about', hash: '#test'}" tag='a' class="green--cta welcome__cta">дознај повеќе</router-link>

First when i click button it sets the location to /about#test but doesn't scroll to the element with that id.I tried to log it into console but when i add hash nothing shows.When i refresh the page it scroll to the element with that id.

0 Answers
Related