vue系列——v-on

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-on指令</title>
</head>
<body>
    <div id="app">
        <input type="button" value="v-on指令" v-on:click="doIt">
        <input type="button" value="v-on指令" @click="doIt">
        <input type="button" value="双击事件" @dblclick="doIt">
        
        <h2 @click="changeFood">{{food}}</h2>
    </div>

    <!-- 开发环境版本,包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

    <script>
        var app=new Vue({
            el:"#app", 
            methods:{
                doIt:function(){ 
                    alert("做it");
                },
                changeFood:function(){
                    console.log(this.food)
                    this.food+="好好吃!"
                }
            },
            data:{
                food:"西兰花炒蛋"
            }
        })
    </script>
</body>
</html>

 

相关推荐

  1. Vue学习v-on

    2024-04-01 14:40:03       35 阅读
  2. vue中使用v-on监听多个方法

    2024-04-01 14:40:03       37 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-01 14:40:03       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-01 14:40:03       106 阅读
  3. 在Django里面运行非项目文件

    2024-04-01 14:40:03       87 阅读
  4. Python语言-面向对象

    2024-04-01 14:40:03       96 阅读

热门阅读

  1. npm 与 yarn 命令比较

    2024-04-01 14:40:03       41 阅读
  2. Spring与Spring Boot的区别

    2024-04-01 14:40:03       36 阅读
  3. 修改aws账户的密码和MFA

    2024-04-01 14:40:03       37 阅读
  4. 【力扣】374.猜数字大小

    2024-04-01 14:40:03       40 阅读
  5. RuoYi-Vue-Plus(登录流程)

    2024-04-01 14:40:03       38 阅读
  6. css去除滑动框

    2024-04-01 14:40:03       41 阅读
  7. pgsql已有表设置主键自增

    2024-04-01 14:40:03       38 阅读
  8. C语言点h文件设置

    2024-04-01 14:40:03       44 阅读