el-input的keyup事件的使用


使用el-input插件后直接使用keyup 是不生效的:

需要在@keyup事件后加上native,即@keyup.enter.native='(方法)':

 

 
 

vue 監聽鍵盤回車事件 @keyup.enter || @keyup.enter.native


<input v-on:keyup.enter="submit">

<input @keyup.enter="submit">

 

全部的鍵盤別名:

 

.enter

.tab

.delete (捕獲 “刪除” 和 “退格” 鍵)

.esc

.space

.up

.down

.left

.right

 

還有一些組合按鍵:

 

.ctrl

.alt

.shift

.meta(window系統下是window鍵,mac下是command鍵)

 

Alt + C :

<input @keyup.alt.67="doSth">

Ctrl + Click :

 

<div @click.ctrl="doSth">點我</div>

 

注意!!!如果用了封裝組件的話,比如element,這個時候使用按鍵修飾符需要加上.native

比如:

<el-input v-model="account" placeholder="請輸入賬號" @keyup.enter.native="search()"></el-input>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM