79641822

Date: 2025-05-28 08:48:11
Score: 0.5
Natty:
Report link
create a function and give a route path as a parameter in this function if the path is same to the route path then use window.scrollTo function and  pass a object. 

const handleSamePageNavigation = (event, path) => {
  if (route.path === path) {
    event.preventDefault();
    window.scrollTo({ top: 0, behavior: "smooth" });
  }
};

and use this function where you use any link like:

<NuxtLink
 to="/about-us"
 @click="
 (e) =>handleSamePageNavigation(e, localePath('/about-us'))">
About 
</NuxtLink>
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Rony