How to get focus from input in ios

try to use
1.vue "s custom instruction v-focus
2.input "s autofocus
3.this.$refs ["input"]. Focus ()
all three methods android can be used to get focus automatically, but ios is not allowed.

Aug.04,2021
Some events on

ios can only be triggered actively by users. The input focus event of ios can be triggered by http://feg.netease.com/archiv.


you can try binding click event on input. Emit click the event when you need to let input get focus.


solved
there was a problem before clicking focus
because the v-show instruction using vue was later rewritten to display:none (although I don't know why,

<div><button onclick="show()">Show Input</button></div>
<div><input style="display: none;" id="input" type="text"></div>
function show() {
    const input = document.querySelector('-sharpinput')

    input.style.display = 'block'
    input.focus()
}

before you call the focus method, nest a setTimeout (fn,10)

Menu