Answer the question
In order to leave comments, you need to log in
How to send data to child component?
I'm from b.d. I get an array of the descendants of the given user, how can I pass them to the child component. Now if I pass it like in the code, then an empty array is passed in the child component. How to transfer?
data(){
return{
partnerChildren: [], //Массив с данными потомков партнера
}
},
methods: {
//Получаем всех потомков данного партнера
getChildrenPartner(){
axios.get('/auth/getChildrenPartner/' + this.$auth.user().inp).then((response)=>{
this.partnerChildren = response.data.children;
});
},
},
mounted() {
Event.$emit('partnerChildren', this.partnerChildren)
},
created(){
//Получим всех потомков партнера
this.getChildrenPartner();
},
Answer the question
In order to leave comments, you need to log in
The parent component should not render the child until enough data has loaded for the child. Something like this:
<template>
<child-component v-if="partnerChildren && partnerChildren.length"></child-component>
<p v-else-if="partnerChildren === null">Загрузка ...</p>
<p v-else>У партнера нет потомков</p>
</template>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question