import Vue from 'vue'
new Vue({
el: '#app',
data: {
},
components: {
"my-header" : {
template: '<h3> this is a parent </h3>',
components:{
"my-top":{
template:'<p>this is a child</p>'
}
}
}
}
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>exprice</title>
</head>
<body>
<div id="app">
<my-header>
</my-header>
</div>
<!-- built files will be auto injected -->
</body>
</html>
最终只能显示 this is a parent.
你在my-header组件里面只是注册了my-top组件却并没有进行调用。将my-header的字符串模板改写为