这是运行结果
直接上代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style>
</style>
<script src="./vue.js"></script>
</head>
<body>
<div id="root">
<!--//使用组件-->
<cpn2></cpn2>
</div>
<script>
//创建组件构造器
const cpn1=Vue.extend({
template:`
<div>
<h2>子组件</h2>
<p>组建的第一个内容</p>
</div>`
});
const cpn2=Vue.extend({
template:`
<div>
<h2>父组件</h2>
<p>组建的第一个内容</p>
<cpn1></cpn1>
</div>`
,
components:{
cpn1:cpn1
},
});
new Vue({
el:"#root",
data:{
},
components:{
cpn2:cpn2
},
methods:{
},
computed:{
},
filters:{ //过滤器
}
})
</script>
</body>
</html>