vue阻止事件冒泡和默認事件

本文地址:http://www.javashuo.com/article/p-daivumti-hh.htmlhtml

原生js取消事件冒泡vue

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

原生js阻止默認事件瀏覽器

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

 

vue.js取消事件冒泡code

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

vue.js阻止默認事件htm

<div @click.prevent="doSomething($event)">vue阻止默認事件</div>
相關文章
相關標籤/搜索