'Do do I unfocus from an input in Vue.JS 2?
Let's suppose I have an input like this:
<input type="text" v-model="x" ref="refInput">
If I want this input to focus programmatically, I can do:
this.$refs['refInput'].focus()
Is there a way to make the input lose the focus programmatically?
I tried this without success:
this.$refs['refInput'].unfocus() // This does not work!
Solution 1:[1]
This is actually a simple JavaScript question. You focus on an input and leave focus with blur. What you need to do is to run the blur function.
example:
this.$refs.refInput.blur()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sami Salih ?brahimba? |
