<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vue.js學(xué)習(xí)模仿用</title>
<script src="../Vue.js/vue.js"></script>
</head>
<body>
<div id="app">
<input type="text" v-model="parentMsg">
<my-component :my-message="parentMsg"></my-component>//注意my-message
</div>
</body>
<script>
//注冊(cè)
Vue.component('my-component',{
props:['my-message'],//注意my-message
template:'<span>{{myMessage}}</span>'//注意myMwssage
})
//初始化根實(shí)例
new Vue({
el:'#app',
data:{
parentMsg:'aa'
}
})
</script>
</html>
三處地方卻又兩個(gè)不同的寫法年局,如果在html里面用-連接字符的話是無法識(shí)別的 逻谦,會(huì)報(bào)錯(cuò)颖变,所以只能用駝峰記法生均,而在Vue.js里駝峰記法和-連接記法一樣。