Vue parent component props are not passing to child component

LLG

I want to get new data from DB with axios in parent component and pass that data to child component. But parent component pass the old data(which is not yet updated with axios.)

I think it is not the problem with axios. Because I can see the new data updated with axios presenting in parent component. But parent component doesn't pass it to child component.

parent component

<template>
<div>
    <p>{{itemData}}</p>
    <child v-bind:propsData="itemData"/>
</div>
</template>

<script>

import Child from './Child.vue'

export default {

  components: {
    Child,
  },

  data(){
    return {
      itemData: {
          title : 'OLD TITLE'
      }
    }
  },

  async created() {
    this.itemData = await this.$axios.get("/rest/getItem/");
    this.itemData = this.itemData.data;
  },

}
</script>

child component

<template>
    <div class="child">
        <li>{{title}}</li>
    </div>
</template>

<script>
export default {
    props: {
      propsData: {
        type: Object
      }
    },

    data(){
        return{
            title: this.propsData.title
        }
    }, 
}
</script>

Actual results

{"title" : "NEW TITLE"}

OLD TITLE

Expected results

{"title" : "NEW TITLE"}

NEW TITLE
men32z

use a computed instead

<script>
export default {
    props: {
      propsData: {
        type: Object
      }
    },

    computed(){
        title(){
          return this.$props.propsData.title
        }
    }, 
}
</script>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to pass multiple props from parent to child component in Vue

Setting props of child component in vue

passing data from child to parent component in Vue

Passing child component class as props to parent component in React

Props Parent component to a parent - child component

Passing the state of a Child component to a Parent?

Passing Props to Child component from Parent using cloneElement

passing a callback function via props to child component is undefined in child vue

Passing props array to child component

Vue - access props in child component

VueJS - Passing props to a child component

Passing props to a Function as a Child component

Reusable Vue component props passing

Problem with passing props to child component

How to ensure that parent is passing populated props to a child component in VueJS

Vue Props in Child component

Passing props and state to child component

Props is not passing in child component in react

Passing props from parent component to child component on dialog box vue

React: Child Component Filtering Parent Component Props

Passing props to child component Cyclejs

Passing child component data to parent using props

passing props from parent to child in react class based component

Passing props from parent component to child components

Passing function via props from Parent to Child component in React?

Passing props that will be used in style in child component - Vue

Passing props to deactivated component in Vue

passing props form child to parent component in react

Vue3 passing props to child component after async call