Vuetify - How to trigger method when clear a v-text-field

廉价感情. 提交于 2019-12-10 13:35:49

问题


is there a way to call a method while clearing a text-field with Vuetify?

<v-text-field
    class="mt-2 mb-0"
    clearable
    solo
    v-model="searchQuery"
    append-icon="search"
    @click:append-outer="searchCos"
   label="Nom de compagnies ou mots-clés">
 </v-text-field>

...
onClear() {
doSomethingHere
}

Thanks

Francis


回答1:


You can use the @click:clear="()" so you can clear your text at the same time it will call the function.

Here's the example

https://codepen.io/anon/pen/ePmLOg?editors=1010




回答2:


Use the clear-icon-cb prop. This allows you to use a custom callback function when the clear icon when clicked.

<v-text-field
  clearable
  :clear-icon-cb="onClearClicked">
</v-text-field>

onClearClicked () {
  // do something
}


来源:https://stackoverflow.com/questions/52573962/vuetify-how-to-trigger-method-when-clear-a-v-text-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!