[Vuejs]-Using multiple $emits in one method

1👍

Both emits would execute, and cause additional load

It is sometimes tempting to think of an $emit as a return. But it isn’t. It does not "end" the component, or the function it is in. It is executed, and then the next $emit is executed in turn.

      this.$emit('changeInput', event)
      this.$emit('changeInputValue', event.target.value)

The load of passing the bigger object will not be significantly larger

Something is going to have to unwrap event to event.target.value. Either the child component or the parent component.

If you think you will ever need the "bigger" object, then pass the bigger object consistently.

i.e. do not do two $emits, just do this:

      this.$emit('changeInput', event)

Leave a comment