<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="myapp">
<!-- 占位符,显示的内容 -->
<demo></demo>
</div>
</body>
</html>
<template id="muban">
<div>
muban内容
<!-- 占位符,显示的内容 -->
<demo2></demo2>
</div>
</template>
<template id='mubantwo'>
<div>
mubantwo的内容
</div>
</template>
<script src="../vue.js"></script>
<script>
// 组件就是一个独立的html+css+js代码块,可以重复使用
//1.创建组件 Vue.component(组件名,{模板键值对,data对象})
Vue.component('demo', {
template: '#muban',
data() {
return {}
}
});
Vue.component('demo2', {
template: '#mubantwo',
data() {
return {}
}
})
new Vue({
el: '#myapp',
data: {},
methods: {
},
})
</script>