router.ts 341 B

1234567891011121314
  1. /**
  2. * Redéfinit le comportement du router quand on navigue vers une ancre
  3. */
  4. export default defineNuxtPlugin(({ $router }) => {
  5. $router.options.scrollBehavior = (to: { hash: any}, from: any, savedPosition: any) => {
  6. if (to.hash) {
  7. return {
  8. el: to.hash,
  9. top: 30,
  10. behavior: 'smooth'
  11. }
  12. }
  13. }
  14. })