Prevent on click on parent when clicking button inside div

前端 未结 5 1856
悲哀的现实
悲哀的现实 2020-12-29 02:03

Is it possible to prevent the function on the

element from running when clicking the button inside the div?

When clicking the button element

5条回答
  •  梦谈多话
    2020-12-29 02:26

    I just want to put my two cents here, since I do find myself looking for this problem again and again (one day I will remember).

    I have found in some instances, the child element needs @click.stop.prevent and that's it, to stop it from bubbling to the parent. I assume v-on:click.stop.prevent would have the same effect (non-shorthand).

提交回复
热议问题