vue基础

<!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>资料</title>
    <style type="text/css">
        [v-cloak] {
            display: none;
        }
    </style>
</head>

<body>
    <div>练习</div>
    <div id="app">
        <div v-cloak>{{msg}}</div>
        <div v-cloak>{{num}}</div>
        <div v-text='mkg'></div>
        <div v-html='mag'></div>
        <div v-once>{{mlk}}</div>
        <div v-pre>{{eee}}</div>
        <div>{{model}}</div>
        <div>
            <input type="text" v-model='model'>
        </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 src="https://unpkg.com/vue/dist/vue.js"></script>
    <script type="text/javascript">
        var vm = new Vue({
            el: "#app",
            data: {
                msg: 'hello world!',
                num: 0,
                mag: '<h1>hello vue!<h1>',
                mkg: 'hello java!',
                mlk: 123,
                eee: 456,
                model: 'model'

            },
            methods: {
                handle: function (){
                    console.log(this === vm)
                    this.num++;
                }
            }
        })

    </script>

</body>

</html>
原文地址:https://www.cnblogs.com/jiaoliuxuexi/p/15083462.html