Diolor
Diolor

Reputation: 13450

How to make router-link consume parent v-on:click completely

<parent v-on:click="isActive = !isActive">
   <router-link :to="{ name: 'home'}">{{tag}}</router-link>
</parent>

If the router-link is clicked the v-on:click in the parent will still capture the event.

How to make the router-link consume the click event completely?

Upvotes: 4

Views: 1484

Answers (1)

Diolor
Diolor

Reputation: 13450

Ok found a workaround. Since router-link renders an a then the v-on:click.stop is not propagated to that rendered a. But if you wrap it with a div which contains the stop, it will work.

<parent v-on:click="isActive = !isActive">
  <div v-on:click.stop>
   <router-link :to="{ name: 'home'}">{{tag}}</router-link>
  </div>
</parent>

Upvotes: 6

Related Questions