zoukankan      html  css  js  c++  java
  • 事件冒泡捕获

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <script src="traceur.js"></script>
        <script src="BrowserSystem.js"></script>
        <script src="bootstrap.js"></script>
        <script src="vue.js"></script>
    </head>
    <script  type="text/traceur">
    window.onload=function(){
    
        var app3 = new Vue({
          el: '#app-3',
          data:{
          },
          
          methods:{
            method1:function(){
                console.log(1);
            },
            method2:function(){
                console.log(2);
            },
            method3:function(){
                console.log(3);
            },
          },
          
          components:{
          },
          
          computed:{
          }
          
        })
        
    };
    
    </script>
    <style>
        .c1{width:300px;height:300px;background-color:blue;}
        .c2{width:200px;height:200px;background-color:red;}
        .c3{width:100px;height:100px;background-color:gray;}
    </style>
    <body>
    <div id="app-3" >
        <div @click="method1" class="c1">
            1 //点击1弹出1
            <div @click.stop='method2' class="c2">
                2 //原来点击2弹出21,加了.stop后,点击2弹出2,点击3弹出32,2收到事件后不再冒泡到外层。
                <div @click="method3" class="c3">
                    3 //点击3弹出321
                </div>
            </div>
        </div>
        
        <div @click.capture="method1" class="c1">
            11  //
            <div @click.capture='method2' class="c2">
                22 // 点击2弹出12
                <div @click="method3" class="c3">
                    33 // 点击3弹出123
                </div>
            </div>
        </div>
    </div>
    </body>
    </html>

  • 相关阅读:
    深入js——this
    深入js——作用域链
    深入js——变量对象
    深入js——执行上下文栈
    vue为什么不能检测数组的变化
    常用的文件下载方式
    vue中修改第三方组件的样式不生效
    Neo4j 学习笔记2
    Neo4j 学习笔记1
    idea git 命令
  • 原文地址:https://www.cnblogs.com/yaowen/p/7098519.html
Copyright © 2011-2022 走看看