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]);
}
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")
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.