[Vuejs]-Vue 2 โ€“ change model in main instance from the component

0๐Ÿ‘

  1. You should not change the parent from child.
  2. To make communication between parent and child (and child->parent as well) you can/should set up the events.
  3. Emit the event in child component. Nice examples here: https://v2.vuejs.org/v2/guide/components.html#Using-v-on-with-Custom-Events
  4. Listen to event in your parent using <child-component @yourEventName='eventHandler(data)'>
  5. Handle data in your parent, so add eventHandler(data) into your methods and do whatever you want with your data.

Leave a comment