1.私有组件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>创建局部组件</title>
<script src="./vue.js"></script>
</head>
<body>
<div id="app">
<templ></templ>
</div>
<script>
var vm=new Vue({
el:'#app',
data:{},
methods:{},
components:{
templ:{
template:'<h1>私有组件</h1>'
}
}
})
</script>
</body>
</html>
2.组件中的data
Vue.component('mycom',{
template:'<h1>第三种方式的组件<h1>--{{ msg }}',
data:function(){
return {
msg:'组件中的data',
}
}
})