What am trying to achieve is to pass data as props in my children components but this data is loaded from the server so it takes a while to load.
I would now like to only mount the children components when the data is fully loaded
SO currently am doing this
IN the parent component
<template>
<child-cmp :value="childdata"></child-cmp>
</template>
<script>
export default{
data(){
childdata : [];
},
methods:{
fetchINitData(){
//fetch from server then
this.childdata = res.data.items;
console.log(res.data.items) //has some values
}
}
components:{
childcmp
},
mounted(){
this.fetchINitData();
}
}
</script>
NOw in my child component
<script>
export default{
props:["value];
mounted(){
console.log(this.value) //this is always empty
}
}
</script>
As from the above example the data passed as props is always empty on the children component. How do i only mount the child component after data has been received or how do i ensure that the childs component get the latest data changed.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…