12-组件分离式写法(配合语法糖)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="./js/vue.min.js"></script>
</head>
<body>
<div id="app">
<cpn></cpn>
<cpn3></cpn3>
</div>
<!-- 分离式写法,能够更好的提示html代码和使得界面的整洁 -->
<template id="cpn1">
<div>
<h1>d4as56d4a564sa5</h1>
</div>
</template>
<template id="cpn2">
<div>
<h1>哈哈哈哈啊哈</h1>
</div>
</template>
<script>
Vue.component('cpn',{
template: '#cpn1'
})
const app = new Vue({
el:"#app",
data(){
return{
}
},
components:{
'cpn3':{
template:'#cpn2'
}
}
})
</script>
</body>
</html>