<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="./vue.js"></script>
</head>
<body>
<div id="root">
<!-- <app></app> -->
</div>
</body>
</html>
<script type="text/javascript">
const student = Vue.extend({
name: 'student',
template: `
<div>
<h2>姓名:{{student_name}}</h2>
<h2>年龄:{{age}}</h2>
</div>`,
data() {
return {
student_name: 'llx',
age: 25
}
}
});
const school = Vue.extend({
name: 'school',
template: `
<div>
<h2>名称:{{school_name}}</h2>
<h2>地址:{{address}}</h2>
<student></student>
</div>`,
components: {
student
},
data() {
return {
school_name: '广职院',
address: '佛山'
}
}
});
const app = Vue.extend({
template: `
<div>
<h2>名称:{{school_name}}</h2>
<h2>地址:{{address}}</h2>
<student></student>
<school></school>
</div>
`,
components: {
school,
student
}
});
new Vue({
template: '<app></app>',
el: '#root',
components: {
app
},
data: {
msg: '欢迎学习Vue!'
}
});
</script>