1. Why output undefined
< html >
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="js/vue.js">
</script>
</head>
<body>
<div id="app">
<button type="button" @click="a"></button>
<div id="app1" ref="myid1">
{{msg1}}
</div>
<aaa :msg2="msg2" ref="mytem1"></aaa>
<button type="button" @click="b"></button>
</div>
<script type="text/javascript">
var vm=new Vue({
data:{
msg1:"hellothis is Dom",
msg2:"this is a template and data form Daddy",
},
methods:{
a:function(){
var idl=this.$refs.myid1.innerHTML;
console.log(idl);
},
b:function(){
var idk=this.$refs.mytem1.innerHTML;
console.log(idk);
},
},
components:{
"aaa":{
template:`
<div>
{{msg2}}
</div>`,
props:["msg2"],
},
},
}).$mount("-sharpapp");
</script>
</body>
< / html >