[Vuejs]-Reactivity in properties not working between controls

0👍

So if I got you right you want to setup two-way data binding for your custom component. So you can use the v-model.

In your child component define the prop and emit value changes.

props: ['userObject'],
methods {
  onUserSelected(items){
    this.$emit('userObject', items);
  }
}

In your parent component add the v-model directive to your child components element:

<div v-if="userObject"> 
   <child v-model="userObject"></child>
   <p class="mb-0">First User: {{this.userObject}}</p>
</div>

Leave a comment