seantrant
11/9/2017 - 1:15 PM

Emit event from child and listen in parent vujs

Emit event from child and listen in parent vujs

// in child 

this.$parent.$emit('removeError', event)

// in parent 

this.$on('removeError', function(){
  console.log('Event from parent component emitted')
  this.errorMessage = 0
});


to pass variables example

// in child

let dimensions = {'posX': item.posX, 'posY': item.posY, 'posZ': item.posZ}
this.$parent.$emit( 'dimensions', dimensions)

// in parent

this.$on('dimensions', (dimensions) => alert(dimensions.posX))