Vue從零開(kāi)始總結(jié)25
之前通過(guò)props實(shí)現(xiàn)了父組件的數(shù)據(jù)傳入子組件并使用,具體實(shí)現(xiàn)如下:
template id="son"
? ?div?
? ?h2? ?{{subMessage}}/h2
? ?/div
/template
const app=new Vue({
el:'#app',
data:{
?message:'hello world'
},
components:{
cpn:{
template:'#son',
props:{
subMessage:String;
}
}
}
})
div id="app"
cpn :sub-message="message" ?/cpn
/div
這節(jié)主要是強(qiáng)調(diào)一下駝峰式命名法,在子組件行內(nèi)的表示方法
-m代替M
標(biāo)簽: