Vue实例(3-1)

Vue实例

还是具体看Vue实例。
el、data是它的属性。
method是方法。
component是模板属性。 它的item其实定义的是标签

<!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>
    <script src='./vue.js'></script>
</head>
<body>
    
    <div id="root">
        <div @click="handleClick">
            {
   
   {message}}
        </div>
        <item></item>
    </div>

    <script>

        Vue.component('item', {
     
     
            template: '<div>hello world</div>'
        })

        var vm = new Vue({
     
     
            el: '#root',
            data: {
     
     
                message: 'hello world'
            },
            methods: {
     
     
                handleClick: function() {
     
     
                    alert("hello")
                }
            }
        })
    </script>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/weixin_45647118/article/details/113828465
3-1