Simple question. I have a router link inside a clickable table row. when I click the router link it triggers the @click event instead of triggering the router-link.
How can I fix this?
<tr v-for="(blabla, index) in data" @click="goToIssue(blabla.id)">
<td>{{ blabla.id }}</td>
<td>{{ blabla.username }}</td>
<td>{{ blabla.name }}</td>
<td>
<router-link
:to="'/project' + blabla.project.id"
>
Details
</router-link>
</td>
</tr>
To stop the
click-event from bubbling to the parent, use a custom<router-link>that uses thestopevent modifier on the underlying link's@click:Apply the
customprop on the<router-link>.In the
<router-link>'s default slot, add an<a>with itshrefbound to the slot'shrefprop.Also add a
click-event handler that calls the slot'snavigateprop (a function that navigates to<router-link>'stoprop). Also apply the.stopevent modifier to theclick-event listener to stop the event from propagating to the parent elements.demo