bir bileşeninden bir olay yayarlar ve dinlemek mümkün olacak bir olay otobüsü kullanabilir ya veya events. Hepsi bileşenleriniz arasındaki ilişkiye göre değişir. , Ebeveyne çocuktan bilgi göndermek için
<template>
<h2>Parent Component</h2>
<child-component :propsName="example"></child-component>
</template>
<script>
export default {
data(){
return{
example: 'Send this variable to the child'
}
}
}
</script>
: Eğer sahne kullanmanız gerekecektir, Çocuk ebeveynden bilgi göndermek için
<template>
<h2>Parent Component</h2>
<child-component></child-component>
</template>
:
en bu küçük bir örnek ele alalım
Çocuk Bileşen
<script>
...
this.$emit('example', this.variable);
</script>
: etkinlikleri kullanmanız gerekecektir
Veli Bileşen
<template>
<h2>Parent Component</h2>
<child-component @example="methodName"></child-component>
</template>
<script>
export default {
methods: {
methodName(variable){
...
}
}
}
</script>
Kontrol Bu konu hakkında daha fazla bilgi için vue.js dokümantasyonu. Bu çok kısa bir giriş.
[State management] (https://vuejs.org/guide/state-management.html) adresindeki Vue guid bölümündeki bölümü okudunuz mu? – PatrickSteele
Henüz değil, ama ihtiyacım olana benziyor. Tüm dökümantasyonu okumayı bitirmeden önce, gelişmeye başlamak için istekli olduğunuzda ne olduğunu tahmin edin. – daniels
Merhabalar! Cevabımı doğru (ve yardımcı) bulduysanız, lütfen [kabul et] (https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) –