How does Mini Program let input get focus through js so as to pop up a soft keyboard?

how can input get focus through js without clicking the input box? How to set up focus?

the soft keyboard pops up when you enter the page for the first time. After putting away the soft keyboard, how to adjust the soft keyboard again?

The input in the

page is written as follows:

<input class="input-code" type="number" focus="{{focus}}" @input="inputCodes" maxlength="6"></input>

add a click event to a view element on the page:

<view class="cont" @tap="openKeyboard"></view>

content of openKeyboard click event:

openKeyboard() {
    this.focus = true;
}

set the variable focus, in data to true, by default to control the acquisition focus of input:

data = {
    focus: true
}

I want to set the soft keyboard by clicking view to trigger the openKeyboard event, but input does not get the focus, and the page does not pop up the soft keyboard. Clicking on other elements does not work. Only by clicking input can we adjust the soft keyboard again. During the period of
, I tried to set the value for input:

<input class="input-code" type="number" focus="{{focus}}" value="inputValue" @input="inputCodes" maxlength="6"></input>

adding adjust-position= "true" and confirm-type= "done" to input still doesn"t work
ask everyone

Aug.31,2021

is that so?

openKeyboard() {
this.setData({
  focus: true
})
}

openKeyboard () {
this.setData ({
focus: false
})
this.setData ({
focus: true
})
}

Menu