Parent component:
<template>
<div>
<child-component :data="parentData"></child-component>
</div>
</template>
<script>
export default {
data() {
return {
parentData: [{info: '123'}, {info: '456'}]
}
},methods: {
init() {
this.parentData = [{info: 'abc'}, {info: 'def'}];
}
},
mounted() {
this.init();
}
}
</script>
Child component:
<template>
<div>
<span v-for="item in parentData">
{{ item.info }}
</span>
</div>
</template>
<script>
export default {
props: ["parentData"]
}
</script>
Initially i am passing some default data, It is get rendering from parent to child.
But after i am updating data for parentData by calling method (which i need to bypass it with api), child component is not geting updated.
Can anyone please help me how to update props in child component by passing updated data for prop from parent component after rendering the page. Thanks in advance.
<child-component :parent-data="parentData">
? Also you need to share how you are updatingparentData
so we know why it's not reactive. – Psidom<child-component :parent-data="parentData">
? your child component has a propparentData
not data. – Psidom