Vue two ways to stop the event bubbling

1. 1 way to prevent the event from bubbling

There follows a click event tag and his son
call stopPropagation in subclasses () method to pass the event of ban

boxClick:function () {
                alert("父标签被点击");
            },
            subClick:function (event) {
                event.stopPropagation();
                alert("子标签被点击了");
            }

2. stop the event bubbling mode 2

Directly behind the event can stop the corresponding tag plus

<div class="box" @click="boxClick()">
        <div class="subClass" @click.stop="subClick($event)"></div>
    </div>
Published 47 original articles · won praise 6 · views 2205

Guess you like

Origin blog.csdn.net/weixin_44467251/article/details/102471181