美文网首页
v-on 事件监听器

v-on 事件监听器

作者: 琪33 | 来源:发表于2018-04-27 15:01 被阅读0次
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>v-on 实例</title>
        <script type="text/javascript" src="../assets/js/vue.js"></script>
    </head>
    <body>
            <h1>v-on 事件监听器</h1>
            <hr>
            <div id="app">
               本场比赛得分: {{count}}<br/>
               <button v-on:click="jiafen">加分</button>
               <button @click="jianfen">减分</button>
               <input type="text" v-on:keyup.enter="onEnter" v-model="secondCount">
            </div>
         
            <script type="text/javascript">
                var app=new Vue({
                    el:'#app',
                    data:{
                        count:1
                    },
                    methods:{
                        jiafen:function(){
                            this.count++;
                        },
                        jianfen:function(){
                            this.count--;
                        },
                        onEnter:function(){
                            this.count=this.count+parseInt(this.secondCount);
                        }
                    }
                })
            </script>
        </body>
        </html>
    

    相关文章

      网友评论

          本文标题:v-on 事件监听器

          本文链接:https://www.haomeiwen.com/subject/thnblftx.html