Home > Software engineering >  @click event not firing on nuxt-link in Nuxt 3
@click event not firing on nuxt-link in Nuxt 3

Time:11-28

According to this Nuxt 2 stack question this should prevent nuxt-link from navigating to a new page:

<nuxt-link :to="`/meet`"  @click.native="event => event.preventDefault()" event="">

but it doesn't. The function inside @click is not executed and nuxt navigates to /meet url.

Any idea how to execute @click events on a nuxt 3 link?

CodePudding user response:

Try to use the prevent modifier and remove :to prop:

<nuxt-link   @click.prevent="yourEventHandler" event="">

then use this.$router.push() inside your event handler

  • Related