[Vuejs]-Vuejs – how to capture the value inside the input name?

1👍

Per the documentation for vue-js-toggle-button events, the event value emitted from a click will be an object containing two properties, value and srcEvent. value is the “state of the object” and srcEvent would be the “source click event”. srcEvent is where you could access target if you need. Try the following:

<toggle-button
  color="rgba(9, 90, 6, 1)"
  @change="SaveConfigFinalSemana($event)"
  name="email" ref='email'
  :labels="{checked: 'Sim', unchecked: 'Não'}"
/>

Here is an example of method/handler SaveConfigFinalSemana logging out the value and srcEvent properties present on the emitted object:

SaveConfigFinalSemana: function($event) {
  console.log($event.value);
  console.log($event.srcEvent);
}

If you need the DOM event target property and the name property of target, you could access it like:

SaveConfigFinalSemana: function($event) {
  console.log($event.srcEvent.target);
  console.log($event.srcEvent.target.name);
}

Here is an example in action.

Hopefully that helps!

Leave a comment