[Vuejs]-Vue dynamic child and sub-child component

0๐Ÿ‘

โœ…

I hope I am understanding properly your problem:

Note: If you create the Contacts vue component within the Address vue component. Vue will assigned each contact to its parent address.

Ex:

Address.vue

<contact :id="this.count"></contact>

If Contacts.vue are created within Address.vue then in Address.vue:

Then in Andress.vue you can create an object or array element:

data(){
  return{
     location: "Any location"
     contacts:[]
  }
}

Then create a function saveContacts:

methods: {
  saveContacts(event, contact){
     this.contacts.push(contact);
  }
}

And finally when you check the event call the function :

@addedContact="saveContact($event,contact)"

This way you will have all addresses with its own contacts. More or less what you showed in your comment.

Hope this can be helpful to you.

๐Ÿ‘คAbel

Leave a comment