Created
January 9, 2019 15:28
-
-
Save hereiscasio/43987662a834abdb86f191ac91bb16c3 to your computer and use it in GitHub Desktop.
Vuetify / Text Field : clear the input by using `ref` only
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<v-footer class="pa-3" absolute> | |
<v-text-field | |
ref="textField" | |
@keyup.enter='sendText' | |
prepend-inner-icon="place" | |
placeholder="Type something here . . ." | |
solo hide-details clearable class="mb-3" | |
/> | |
</v-footer> | |
</template> | |
<script> | |
export default { | |
methods: { | |
sendText(e) { | |
if ( !e.target.value ) return; // reject empty msg | |
this.$refs.textField.$el.getElementsByTagName('input')[0].value = ''; | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
but that value will "come back" after blur the
v-text-field
,so use
v-model
is the best way