When I click an anchor with a href like this href='#title'
I expect the page to scroll to the element that contains the id='title'
.`
Instead it reloads the page and if I click it a second time only then it works. I am using vue-router and this is the router.options
:
import type { RouterOptions } from '@nuxt/schema'
export default <RouterOptions>{
strict: true,
scrollBehavior: function (to, _from, savedPosition) {
if (savedPosition) {
return savedPosition
} else if (to.hash) {
return {
el: to.hash,
}
} else {
return {
left: 0,
top: 0,
}
}
},
}