zoukankan      html  css  js  c++  java
  • vue(8)事件监听v-on

    <template>
        <div>
          <button v-on:click="sub('test',$event)">-</button>//v-on表示绑定事件,这里绑定click还有很多其他时间比如鼠标移入移出等等,用法都一样
    //将click绑定到sub方法,并且传入了两个参数,一个是字符串test,另一个$event表示事件属性这个属性中包括事件触发的详细信息比如点击的坐标信息等
          <input type="text" v-model="num">//双向绑定num变量
          <button @click="add($event)">+</button>//@click的意思和上面的v-on:click是相等的,@click相等于一个简写方式
        </div>
    </template>

    <script>
    export default {
       name:"App",
       data:function(){
           return {
              num:0
                };
       },
       computed:{
           
       },
       methods:{
           sub:function(data,e){
               console.log(data);
               console.log(e);
               this.num--;
           },
           add:function(e){
               console.log(e);
               this.mun++;
           }
       }
    }
    </script>

    <style scoped>
    </style>
  • 相关阅读:
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    thinkphp使用foreach遍历的方法
    php中foreach中使用&的办法
    thinkphp做搜索功能
    数据库虚拟主机目录的配置文件
    网页响应式设计原理
    数据库常见远程连接问题
  • 原文地址:https://www.cnblogs.com/maycpou/p/14697728.html
Copyright © 2011-2022 走看看