Vue judges whether the input box gets the focus and loses the focus, so that the input box automatically gets the focus

<input type="text" @focus="searchfun" @blur="searchfun_close" ref="inputref">
//input失去焦点时执行的方法
searchfun_close(){
    this.searchpopupShow=false
},
//input当前获取焦点执行的方法
searchfun(){
    this.searchpopupShow=true
},

//让input框获取焦点
searchfuns(){
    this.$refs.inputref.focus()
}

The @focus method is executed when the focus is obtained

The @blur method is executed when the focus is lost

Let the input box get the focus through ref

Guess you like

Origin blog.csdn.net/stars______/article/details/129859019