..."."/> ...".">

Home >Web Front-end >Vue.js >How to cancel bubbling in vuejs

How to cancel bubbling in vuejs

藏色散人
藏色散人Original
2021-09-18 11:37:043432browse

Vuejs method to cancel bubbling: 1. Open the corresponding vue file; 2. Pass "3c01280be79d064469c568c1b55fe1fa...16b28748ea4df4d9c2150843fecfba68 " method to cancel event bubbling.

How to cancel bubbling in vuejs

The operating environment of this article: windows7 system, vue2.5.17 version, DELL G3 computer.

How to cancel bubbling in vuejs?

vue.js prevents event bubbling and default events

Native js cancels event bubbling

    try{
        e.stopPropagation();//非IE浏览器
    }
    catch(e){
        window.event.cancelBubble = true;//IE浏览器
    }


Native js blocks default events

if ( e && e.preventDefault ) {
            e.preventDefault()//非IE浏览器
} else { window.event.returnValue = false; } //IE浏览器

vue.js cancels event bubbling

<div @click.stop="doSomething($event)">vue取消事件冒泡</div>

vue.js blocks default events

<div @click.prevent="doSomething($event)">vue阻止默认事件</div>

Recommended learning :《vue tutorial

The above is the detailed content of How to cancel bubbling in vuejs. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn