Child and parent ripple triggered

半腔热情 提交于 2020-04-13 18:34:26

问题


I'm using vuetify to design a 'card' component.

I have a parent div with a child button. Now, when I click the button, the ripple effect on the div is triggered.

How can I fix this?

<template>

  <div>

    <v-card v-ripple="true">
      <h3>
        <v-card-title>{{ title }}</v-card-title>
      </h3>

      <v-layout row>
        <v-flex grow>
          <v-card-text>
            {{ plaats }}
            <br />
            {{ sub_title }}
          </v-card-text>
        </v-flex>

        <v-flex shrink>
          <v-card-actions>

            <v-btn small color="blue" fab>
              <v-icon medium color="white">mdi-calendar</v-icon>
            </v-btn>

            <v-btn small color="green" fab>
              <v-icon medium color="white">mdi-calendar-check</v-icon>
            </v-btn>

            <v-btn small color="red" fab>
              <v-icon medium color="white">mdi-calendar-remove</v-icon>
            </v-btn>

          </v-card-actions>
        </v-flex>

      </v-layout>
    </v-card>

  </div>

</template>

回答1:


The solution was indeed Event.stopPropagation but I had to add it to the mousedown action. So @mousedown.stop and then add your function with @click.stop="null" as @Frank mentioned before.




回答2:


You're looking for Event.stopPropagation. Add @click.stop="null" to your button(s). Of course you can/should replace null with your own method.




回答3:


Note @mousedown event will not fire on mobile, thus we also need to add @touchstart.

Codepen

<v-list>
  <v-list-tile :ripple="true" @click="">

    <v-list-tile-action>
      <v-btn 
          @click.stop="" 
          @mousedown.stop="" 
          @touchstart.stop=""
      >Click</v-btn>
    </v-list-tile-action>

    <v-list-tile-content class="pl-5">
      Click tile
    </v-list-tile-content>

  </v-list-tile>
</v-list>


来源:https://stackoverflow.com/questions/54536822/child-and-parent-ripple-triggered

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!