javascript - Add modifier to v-on in menu activator using Vuetify - Stack Overflow

Simplified example:<v-list><v-list-item :to="blabla"><v-menu><template

Simplified example:

<v-list>
  <v-list-item :to="bla/bla">
    <v-menu>
      <template v-slot:activator="{on}">
        <v-btn v-on.prevent="on"/> // I tried .stop, .stop.prevent, self.prevent, prevent.stop
      </template>
      <div> bla </div>
    <v-menu>   
  </v-list-item>
</v-list>

So as you can see child event v-on triggers v-menu and shows this div. But it also triggers parent :to event. Any ides?

Simplified example:

<v-list>
  <v-list-item :to="bla/bla">
    <v-menu>
      <template v-slot:activator="{on}">
        <v-btn v-on.prevent="on"/> // I tried .stop, .stop.prevent, self.prevent, prevent.stop
      </template>
      <div> bla </div>
    <v-menu>   
  </v-list-item>
</v-list>

So as you can see child event v-on triggers v-menu and shows this div. But it also triggers parent :to event. Any ides?

Share Improve this question edited Nov 30, 2021 at 19:46 Boussadjra Brahim 1 asked Sep 18, 2020 at 11:48 Borna MarinBorna Marin 1137 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 6

Try to destruct the on slot prop as follows :

  <template v-slot:activator="{ on: { click } }">
        <v-btn  v-on:click.stop.prevent="click">
          open
          </v-btn>
      </template>

You are using the event modifier on v-on, no on v-on.click.

You can stop the propagation by adding @click with the modifier separately to the button:

<v-btn v-on="on" @click.stop.prevent />

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745642020a4637749.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信