<!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="app">
<child-component></child-component>
</div>
<template id="chrent">
<div>
这是一个子组件{{msg}}
</div>
</template>
<script src="vue.js"></script>
<script>
var vm=new Vue({
el:'#app',
data:{
message:'Hello Vue.js!'
},
components:{
'child-component':{
template:chrent,
data:function(){
return{
msg:'I am a child component.'
}
}
}
}
})
</script>
</body>
</html>
标签:Vue,局部,component,msg,child,组件,data
From: https://www.cnblogs.com/zy8899/p/18410147