vue.js 語法

Sending Data into a component requires Prop, Sending data out of Component requires Emit

Data Exchange between sibling component is achieved by Central Event Bus. Complicated sibling component data changes uses VueX

component包含 Template, Data, props, methods ?其中Template是必須要的

Register component


install component






如果要從data() 里使用props的值: this.prop

send data out of component:


v-bind和v-model都是讓external data進(jìn)入的




經(jīng)典啊????????

這里是一個(gè)使用event驅(qū)動(dòng)emit 函數(shù) 把數(shù)據(jù)從component.data傳遞到Vue.data里的例子。這個(gè)例子展現(xiàn)了傳入component以及傳出component

首先Input的地方用v-model 和component.message綁定起來。 這樣數(shù)據(jù)傳入了component里。

然后定義Event: v-on: click='send' ?調(diào)用了this.$emit()。 this.emit把message傳入Vue.content里 通過v-on:relay='function' 這個(gè)Tag。 content注意! 在P tag里refer了。。。 {{content}}

V-model = V-bind + V-on



同時(shí)send Multiple data



Sibling components communication?





?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容