讓element ui的輸入框聚焦的4種方式

2021-10-23 08:06:14 字數 966 閱讀 1491

方法

一、繫結ref

方法二、通過自定義事件中的事件物件 $event,找到input

方法三、使用自定義指令

方法四、使用原生input

方法

一、繫結ref——參考yiyueqinghui

"form.name" ref=

"name"

>

<

/el-input>

this

.$refs.name.

focus()

;

方法二、通過事件中的事件物件 $event,找到input——參考z.r.j

"form.name" ref=

"name" @key.enter.native=

"inputfocus($event)"

>

<

/el-input>

inputfocus

(e)

方法三、使用自定義指令——官網

方法四、使用原生——參考 蘿蔔愛吃青菜

"text" id=

"username" name=

"username" autofocus=

"autofocus"

/>

this

.$nexttick((

)=>

)

案例、進入登入頁時,使用者名稱輸入框自動聚焦、按enter鍵讓密碼框聚焦,完整輸入資訊後登入

Element UI的復合輸入框應用

工作需求 應用復合輸入框支援右側下拉選項 左側支援輸入 當左側輸入時候右側下拉清空 如下 html 請輸入應用鏈結 value datadetail.url class input width select style width 80 focus getvalue input changinput...

當鍵盤擋住輸入框的時候讓輸入框往上移動

用的是通知 當鍵盤出現時 nsnotificationcenter defaultcenter addobserver self selector selector keyboardwillshow name uikeyboardwillshownotification object nil 當鍵盤...

ElementUI 輸入框模糊搜尋資料處理的坑

前言 最近在遇到乙個需求,輸入框 input 模糊搜尋的功能,我用到的是elementui的el autocomplete 元件,但是在使用的過程中遇到了一些坑,分享一下 坑1 根據官方提供的方法 querysearch querystring,cb customerorderapi.getumli...