<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
<div id="app">
<comp>
</comp>
</div>
<script>
// 创建的是 Vue 构造器
// 子组件
const comp1 = Vue.extend({
template: `
<div id="">
<p>Hello Vue.js!</p>
</div>`
})
// 父组件
const comp2 = Vue.extend({
template: `
<div id="">
<p>Hello furong!</p>
<comp1></comp1>
</div>`,
components: {
comp1: comp1,
}
})
// root
const app = new Vue({
el: '#app',
data: {
message: 'Hello Vue.js!',
},
components: {
comp: comp2,
}
})
</script>
</body>
</html>