Skip to content Skip to sidebar Skip to footer

How To Pass Function As A Prop To Child Component And Call It From There In Vue?

I know its not advised to pass function as a prop to the child component in Vue. But if I were to do it, how is that possible? This is what I have tried till now - My child compon

Solution 1:

You could emit an event from the child component and run it inside the parent one :

@mouseover="$emit('show_divs',$event)"

in the parent component :

  v-on:show_divs="show_divs"

method :

methods:{
  show_divs(event){
    console.log(event)
  }
}

Post a Comment for "How To Pass Function As A Prop To Child Component And Call It From There In Vue?"