I have a <router-link />
that I want to use to navigate to another page in a Vue 3 application, but I also want to run another function when this link is clicked.
Right now I have to use an extra <span />
element to wrap the <router-link />
and add the @click
attribute there to rely on event bubbling. Adding the @click
handler on <router-link />
causes the router link not to work and the browser thinks it is just a normal anchor href.
<span @click="handleClose(imageId)">
<router-link
:to="{name: 'image', params: {'imageId': imageId}}"
class="permalink">
Permalink
</router-link>
</span>
Is there a better way?