0

How do I pass the this object (referring to the input element vs. whole component) to a handler function in Vue?

<input
  type="number"
  min="0"
  max="8000000"
  step="100000"
  v-model="minPriceInput"
  @change="setPriceRange(minPriceInput, maxPriceInput)"
/>

methods:

setPriceRange(min, max) {
  this.blur(); // or whatever else I might do with the input
  state.commit("setPriceRange", [min, max]);
}
SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
Kirk Ross
  • 6,413
  • 13
  • 61
  • 104

1 Answers1

1

You can pass the event with the parameters as follows setPriceRange($event, minPriceInput, maxPriceInput); and use it through event.target. Another thing you can do is giving it an id and calling it normally using document.getElementById("minPrice")...

Majed Badawi
  • 27,616
  • 4
  • 25
  • 48