Blogger Information
Blog 250
fans 3
comment 0
visits 322833
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Vue自学:父组件和子组件的区别
梁凯达的博客
Original
1778 people have browsed it

<!DOCTYPE html>

<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title></title>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.12"></script>
<title>Vue自学:父组件和子组件的区别</title>
</head>
<body>
<div id="app">
<cpn2></cpn2>
</div>
</body>
<script type="text/javascript">
//创建全局构造器1(子组件)
const cpn1 = Vue.extend({
template:
<div> <h1>这是cpn1</h1> <p1>这是cpn1</p1> </div>
})
//创建全局构造器2(父组件)
const cpn2 = Vue.extend({
template:
<div> <h1>这是cpn2</h1> <cpn1></cpn1> </div>,
components:{
cpn1:cpn1
}
})

//约定俗成的说法,Vue本身也是一个组件
//称作 ROOT 组件
const app = new Vue({
el:’#app’,
data:{

},
components:{
cpn2:cpn2,
}
})

//语法糖写法
const app = new Vue({
el:’#app’,
data:{

},
components:{
‘cpn2’:{
template:
<div> <h1>这是cpn2</h1> <cpn1></cpn1> </div>
}
}
})
</script>
</html>

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post