zoukankan      html  css  js  c++  java
  • VUE调用函数,以及event的讲解

    先看我们是如何定义函数的

    var vm = new Vue({
        //找到ID为APP的作用域 el:
    "#app",
          //数据 data: { msg:
    "Hello Vue", num: 0 },
          //methods就是VUE中函数的定义处 methods: {
           //函数名称 函数体 handle:
    function (event) {
              //查看当前触发函数的内容 console.log(event.target.value);
    this.num++; }, handle1: function (event) {
              //查看触发函数的标签 console.log(event.target.tagName); console.log(event.target.value);
    //目前为止,innerHTML在MVC中好像不管用,获取不到值 console.log(event.target.innerHTML) this.num++; } } })
    @*$event传参,固定名称
            事件绑定--参数传递
                1、如果时间直接绑定函数名称如同v-on:click="handle",那么默认会传递事件对象作为事件参数的第一个参数
                2、如果时间绑定函数调用如 v-on:click="handle1($event)",那么事件对象必须作为最后一个参数显示传递,并且事件的名称必须是$event
            *@
            @*使用方法进行num自增,方法的定义是methods*@
            <input id="Button1" v-on:click="handle" type="button" value="事件绑定数值自增" />
            <input id="Button1" v-on:click="handle1($event)" type="button" value="事件绑定数值自增" />

    以上的代码就是说明了函数的定义,以及调用,event的一个介绍

  • 相关阅读:
    课件的引子
    用nc做网络压力测试
    分布式计算学习笔记
    静态库 .a 转成共享库 .so
    nmon用法
    eclipse debug URLClassPath.getLoader(int) file
    sodu 命令场景分析
    俩孩随笔
    深度学习丨深度学习中GPU和显存分析
    语义分割丨DeepLab系列总结「v1、v2、v3、v3+」
  • 原文地址:https://www.cnblogs.com/ShenJA/p/11791006.html
Copyright © 2011-2022 走看看