简体   繁体   中英

@click event not firing on nuxt-link in Nuxt 3

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

<nuxt-link :to="`/meet`" class="group font-normal" @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 ?

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

<nuxt-link  class="group font-normal" @click.prevent="yourEventHandler" event="">

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM