Vue 组件 父子组件

技术QQ交流群:294088839

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue 组件</title>
    <script type="text/javascript" src="../assets/js/vue.js"></script>
</head>
<body>
<h1>Vue 组件</h1>
<hr>
<div id="app">

    <whl>

    </whl>
</div>

</body>
</html>
<script>
    //子组件
    var city={
        template:`<div style="color:dodgerblue">我是河南人</div>`
    };
    //在外部声明一个组件
    //父组件
     var panda={
         template:`
                 <div>
                    <p style="color:red">我是河南来的</p>
                    <city></city>
                </div>
            `,
         components:{
             'city':city
         }
     };
    //爷爷
    var app = new Vue({
        el:'#app',
        components:{
            'whl':panda
        }

    });

</script>

猜你喜欢

转载自blog.csdn.net/drug_/article/details/81109477