[英]How to pass "this" as well as v-model from input to handler
如何將this
對象(指輸入元素與整個組件)傳遞給 Vue 中的處理程序函數?
<input
type="number"
min="0"
max="8000000"
step="100000"
v-model="minPriceInput"
@change="setPriceRange(minPriceInput, maxPriceInput)"
/>
方法:
setPriceRange(min, max) {
this.blur(); // or whatever else I might do with the input
state.commit("setPriceRange", [min, max]);
}
您可以使用如下參數傳遞事件setPriceRange($event, minPriceInput, maxPriceInput);
並通過event.target
使用它。 你可以做的另一件事是給它一個 id 並使用document.getElementById("minPrice")
正常調用它......
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.