问题
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