绑定事件

1、案例1

<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>绑定事件</title>
</head>

<body>
    <div id="app">
        <!--v-on:可简写为@-->
        <button v-on:click="func1('我是按钮1')">按钮1</button>
        <button @click="func2()">按钮2</button>
    </div>
    <script src="../js/vue.js" type="text/javascript"></script>
    <script>
        const vm = new Vue({
            el: "#app",
            data: {
            },
            methods: {
                func1(param) {
                    alert(param);
                },
                func2() {
                    alert("我是按钮2");
                }
            }
        });
    </script>
</body>

</html>

 

posted @ 2020-03-08 14:18  牛牛的自留地  阅读(82)  评论(0编辑  收藏  举报