【问题标题】:How to pass "this" as well as v-model from input to handler如何将“this”以及 v-model 从输入传递到处理程序
【发布时间】:2020-07-10 05:18:56
【问题描述】:

如何将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]);
}

【问题讨论】:

    标签: javascript vue.js this v-model


    【解决方案1】:

    您可以通过setPriceRange($event, minPriceInput, maxPriceInput);的参数传递事件,并通过event.target使用它。 您可以做的另一件事是给它一个 id 并使用 document.getElementById("minPrice") 正常调用它...

    【讨论】:

      猜你喜欢
      • 2019-02-15
      • 2019-11-19
      • 1970-01-01
      • 1970-01-01
      • 2011-07-26
      • 2021-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多