hereiscasio
1/9/2019 - 3:28 PM

Vuetify / Text Field : clear the input by using `ref` only

Vuetify / Text Field : clear the input by using ref only

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