vue中阻止事件穿透的方法


默認情況下,事件在h5頁面會穿透傳遞,比如一div里面套一個div,點擊上層div,下層div也會響應
要阻止事件穿透,使用event.stopPropagation();
代碼示例:

<div @click="testout($event)>
<div @click="testin($event)"></div>
</div>
.......

testin(event) {
      ......
      event.stopPropagation();
    },


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM