父子组件的创建,使用
组件的使用
- 组件的创建
- 组件的注册
- 组件的使用
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="app">
{{message}}
<cnp></cnp>
<cnp></cnp>
<cnp></cnp>
</div>
<script src="../vue.js"></script>
<script>
const cnp = Vue.extend({
template:`
<h1>我是一个组件</h1>
<h3>怎么样</h3>
`
})
// Vue.component('cnp',cnp)
const app = new Vue({
el: '#app',
data: {
message: 'hello'
},
components: {
cnp
}
})
</script>
</body>
</html>