vue.js:v-on指令


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        {{msg}}
        <input type="button" value="v-on指令" v-on:click="doWeb">
        <input type="button" value="v-on简写" @click="doWeb">
        <input type="button" value="双击事件" @dblclick="doWeb">
        <h1 @click="changeYear">{{year}}</h1>
    </div>
    <!-- <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> -->
    <script src="./vue.js"></script>
    <script>
        var app =  new Vue({
            el:"#app",
            data:{
                msg:"888",
                year:2019
            },
            methods:{
                doWeb:function(){
                    console.log("999");
                },
                changeYear:function(){
                    this.year=2020;
                }
            }
        })
    </script>
</body>
</html>

vue.js:v-on指令(图1)

您可能还会对下面的文章感兴趣: