vue--04

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style type="text/css">
    [v-cloak] {
        display: none;
    }
</style>

<body>
    <div id="app">
        <div v-cloak>{{msg}}</div>
        <div>{{1 + 9}}</div>
        <div>{{msg + '---' + 123}}</div>
        <div v-html='mag'></div>
        <div v-pre>{{mag}}</div>
        <div v-text>{{msg}}</div>
        <div v-once>{{info}}</div>
        <div>{{mhg}}</div>
        <div>
            <input type="text" v-model="mhg">
        </div>
        <div>{{num}}</div>
        <div>
            <button v-on:click='num++'>点击01</button>
            <button @click='num++'>点击02</button>
            <button @click='handle'>点击03</button>
            <button @click='handle()'>点击04</button>
        </div>
    </div>
    <script type="text/javascript" src="js/vue.js"></script>
    <script type="text/javascript">

        var vm = new Vue({
            el: '#app',
            data: {
                msg: 'hello!',
                mag: '<h1>hello vue<h1>',
                info: 'python',
                mhg: 'java',
                num : 0
            },

            methods: {
                handle: function() {
                    console.log(this === vm)
                    // 这里的this是Vue的实例对象+
                    //   在函数中 想要使用data里面的数据 一定要加this 

                    this.num++;
                }
            }
        })

    </script>

</body>

</html>
posted @ 2021-08-02 10:55  上海颖  阅读(28)  评论(0编辑  收藏  举报