组件嵌套

2019-07-22  本文已影响0人  0981b16f19c7

father组件是vue实例的子组件,是child组件的父组件;
child是father组件的子组件。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>my vue learn</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app1">
    <father-component></father-component>
</div>
<script>
    var child = {
        template:"<h1>我是最底层的子组件</h1>"
    };
    
    var father={
        template:"<div><child-component></child-component></div>",
        components:{
            "child-component":child
        }
    };
    
    new Vue({
        el: "#app1",
        components:{
            "father-component":father
        }
    });
</script>
</body>
</html>
上一篇 下一篇

猜你喜欢

热点阅读