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>
网友评论