Vuejs - how to remove event onPressKey on a simple input type text

429 views Asked by At

I have a simple input type text and I want to remove the onKeyPress for performance.

I tested many solution like this by it doesn't work. I see again event press on performance tab in chrome navigator

mounted() {
    const doc = document.getElementById('input-simple-text')
    doc.onkeydown = null
}

// simple input
 <input  class="form-control"
         id="input-simple-text"
         type="text"
         v-model="mutableValue"
         ref="input" />

If you have solutions to delete this events , thanks

1

There are 1 answers

1
Stefan On

According to the documentation, you have quite a lot of possibilities. One of them is to prevent the event or stop its propagation. https://v2.vuejs.org/v2/guide/events.html#Event-Modifiers

<input  class="form-control"
         id="input-simple-text"
         type="text"
         v-model="mutableValue"
         v-on:keyup="$event.preventDefault()"
         ref="input" />