vue中特殊的键盘修饰符,不必去记特定的keyCode:
@keyup.13 == @keyup.enter
@keyup.9 == @keyup.tab
@keyup.46 == @keyup.delete (捕获 “删除” 和 “退格” 键)
@keyup.27 == @keyup.esc
@keyup.32 == @keyup.space
@keyup.38 == @keyup.up
@keyup.40 == @keyup.down
@keyup.37 == @keyup.left
@keyup.39 == @keyup.right
@keyup.13 == @keyup.ctrl
@keyup.18 == @keyup.alt
@keyup.16 == @keyup.shift
@keyup.13 == @keyup.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>
Logo

前往低代码交流专区

更多推荐