Vue父子组件
<!DOCTYPE html><html><head><meta charset="UTF-8"><script type="text/javascript" src="js/vue.js"></script><title></title></head>&l...
·
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="js/vue.js"></script>
<title></title>
</head>
<body>
<h1>component-1</h1>
<hr>
<div id="app">
<panda></panda>
</div>
<script type="text/javascript">
//子组件
var city={
template:`<div style="color:green;">sichuan of china</div>`
}
//父组件 --父组件引用子组件
var pandaCpmponent = {
template:`
<div>
<p style="color:red;">Panda from china</p>
<city></city>
</div>
`,
components:{
"city":city
}
}
var app=new Vue({
el:'#app',
components:{
"panda":pandaCpmponent
},
data:{
message:'china'
},
})
</script>
</body>
</html>
更多推荐
已为社区贡献7条内容
所有评论(0)