Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

how to call parent method from child component

You should use this.$emit('myEvent') inside of your child component, when you want to trigger the method in the parent.

Then find you child component in the template of the parent and add an event catcher on it like this:

<template>
  <your-child-component @myEvent="myMethod"/>
</template>
If you want to add parameters to your method, you can add a second parameter to your emit like this:

this.$emit("myEvent", "My parameter")
For this to work you don't have to change anything in the event "catcher", as long as the method you call has a parameter
Source by www.titanwolf.org #
 
PREVIOUS NEXT
Tagged: #call #parent #method #child #component
ADD COMMENT
Topic
Name
9+7 =