zoukankan      html  css  js  c++  java
  • vue3事件

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
    
        </style>
        <script src="vue.js"></script>
        <script>
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{},
                    methods:{
                        show:function(ev,b){
                            alert(ev.clientX);
                            alert(b);
                        }
                        show2:function(){
                            alert(2);
                        }
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">
            <input type="button" value="按钮" @click="show($event,12)">
            <input type="button" value="按钮" @click="show()">
            <!--  v-on:click="show()"简写  -->
        </div>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
    
        </style>
        <script src="vue.js"></script>
        <script>
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{ },
                    methods:{
                        show:function(ev){
                            alert(1);
                            ev.cancelBubble=true;//阻止冒泡
                        },
                        show2:function(){
                            alert(2);
                        }
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">
            <div @click="show2()">   //冒泡
                <input type="button" value="按钮" @click="show($event)">
            </div>
        </div>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
    
        </style>
        <script src="vue.js"></script>
        <script>
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{ },
                    methods:{
                        show:function(){
                            alert(1);
                        },
                        show2:function(){
                            alert(2);
                        }
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">
            <div @click="show2()">
                <input type="button" value="按钮" @click.stop="show()">  简写方式,阻止冒泡,
            </div>
        </div>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
    
        </style>
        <script src="vue.js"></script>
        <script>
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{ },
                    methods:{
                        show:function(ev){
                            alert(1);
                            ev.preventDefault();//阻止右键菜单出来
                        }
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">
            <input type="button" value="按钮" @contextmenu="show($event)">    //contextmenu右键点击
        </div>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
    
        </style>
        <script src="vue.js"></script>
        <script>
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{ },
                    methods:{
                        show:function(){
                            alert(1);
                        }
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">
            <input type="button" value="按钮" @contextmenu.prevent="show()">    //阻止右键的默认行为
        </div>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
    
        </style>
        <script src="vue.js"></script>
        <script>
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{
    
                    },
                    methods:{
                        show:function(ev){
                            alert(ev.keyCode);
                            if(ev.keyCode==13){
                                alert('您按回车了');
                            }
                        }
                        show1:function(){
                            alert('您按回车了');
                        }
                        show2:function(){
                            alert('您按回车了');
                        }
                        show3:function(){
                            alert(1);
                        }
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">
            <input type="text" @keydown="show">
            <input type="text" @keydown="show($event)">
            <input type="text" @keyup="show($event)">
            <input type="text" @keyup.13="show1()">
            <input type="text" @keyup.enter="show2()">
            <input type="text" @keyup.left="show3()">
            <input type="text" @keyup.up="show3()">
        </div>
    </body>
    </html>
  • 相关阅读:
    用DeBug的方式,带你掌握HBase文件在Snapshot的各种变化
    业务随行:用户的网络访问策略还能这么玩
    清明节特辑 |记忆存储、声音还原、性格模仿……AI可以让人类永生吗?
    答题拿奖两不误:华为云知乎金牌答题官,就是你!
    一文掌握GaussDB(DWS) SQL进阶技能:全文检索
    LiteOS内核源码分析:任务栈信息
    INTERSPEECH2020 语音情感分析论文之我见
    统一元数据,数据湖Catalog让大数据存算分离不再是问题
    云图说|将源端MongoDB业务搬迁至华为云DDS的几种方式
    跟我学丨如何用鲲鹏服务器搭建Hadoop全分布式集群
  • 原文地址:https://www.cnblogs.com/yaowen/p/6974056.html
Copyright © 2011-2022 走看看