vue+elementui 中 @keyup 键盘上下左右移动聚焦
<template>
<el-table :data="CreditUnclearOutlineList" border style="width: 100%" ref="table">
<el-table-column align="center" prop="name" label="名称" width="150">
</el-table-column>
<el-table-column align="center" label="正常">
<el-table-column align="center" sortable prop="normalB" label="笔数">
<template scope="scope">
<span>
<el-input style="width: 90px" placeholder="笔数" v-model="scope.row.normalB" @change="handleCreditChange()" class="table_input normalB_input" @keyup.native="show($event,scope.$index)"></el-input>
</span>
</template>
</el-table-column>
<el-table-column align="center" sortable prop="normalY" label="余额(万元)">
<template scope="scope">
<span>
<el-input style="width: 90px" placeholder="余额" v-model="scope.row.normalY" @change="handleCreditChange()" @blur="handleBalanceBlur($event)" @focus="handleBalanceClear($event)" class="table_input normalY_input" @keyup.native="show($event,scope.$index)"></el-input>
</span>
</template>
</el-table-column>
</el-table-column>
<el-table-column align="center" label="关注">
<el-table-column align="center" sortable prop="focusB" label="笔数">
<template scope="scope">
<span>
<el-input style="width: 90px" placeholder="笔数" v-model="scope.row.focusB" @change="handleCreditChange()" class="table_input focusB_input" @keyup.native="show($event,scope.$index)"></el-input>
</span>
</template>
</el-table-column>
<el-table-column align="center" sortable prop="focusY" label="余额(万元)">
<template scope="scope">
<span>
<el-input style="width: 90px" placeholder="余额" v-model="scope.row.focusY" @change="handleCreditChange()" @blur="handleBalanceBlur($event)" @focus="handleBalanceClear($event)" class="table_input focusY_input" @keyup.native="show($event,scope.$index)"></el-input>
</span>
</template>
</el-table-column>
</el-table-column>
<el-table-column align="center" label="不良">
<el-table-column align="center" sortable prop="badB" label="笔数">
<template scope="scope">
<span>
<el-input style="width: 90px" placeholder="笔数" v-model="scope.row.badB" @change="handleCreditChange()" class="table_input badB_input" @keyup.native="show($event,scope.$index)"></el-input>
</span>
</template>
</el-table-column>
<el-table-column align="center" sortable prop="badY" label="余额(万元)">
<template scope="scope">
<span>
<el-input style="width: 90px" placeholder="余额" v-model="scope.row.badY" @change="handleCreditChange()" @blur="handleBalanceBlur($event)" @focus="handleBalanceClear($event)" class="table_input badY_input" @keyup.native="show($event,scope.$index)"></el-input>
</span>
</template>
</el-table-column>
</el-table-column>
<el-table-column align="center" prop="amountY" sortable label="余额(万元)">
<template scope="scope">
<span>{{scope.row.amountY}}</span>
</template>
</el-table-column>
</el-table>
</template>
//键盘触发事件
show(ev,index){ let newIndex ; //通过ev 获取 当前input 名称 用于判断属于哪列
let clssName = ev.target.offsetParent.className; //每一列
if(clssName.indexOf('normalB_input') != -1){ newIndex = index*6 ; } else if (clssName.indexOf('normalY_input') != -1) { newIndex = index*6 + 1 ; } else if (clssName.indexOf('focusB_input') != -1) { newIndex = index*6 + 2; } else if (clssName.indexOf('focusY_input') != -1) { newIndex = index*6 + 3; } else if (clssName.indexOf('badB_input') != -1) { newIndex = index*6 + 4; } else if (clssName.indexOf('badY_input') != -1) { newIndex = index*6 + 5; } //获取每一列的input名称
let normalB_input = document.getElementsByClassName('normalB_input')
let normalY_input = document.getElementsByClassName('normalY_input')
let focusB_input = document.getElementsByClassName('focusB_input')
let focusY_input = document.getElementsByClassName('focusY_input')
let badB_input = document.getElementsByClassName('badB_input')
let badY_input = document.getElementsByClassName('badY_input') //获取54个input
let inputAll = document.querySelectorAll('.table_input input'); //向上 =38
if(ev.keyCode == 38){
//当焦点在第一行的时候 按向上的时候焦点要聚焦到前一列的最后一个
if(newIndex >=1 && newIndex<=5){
newIndex = newIndex + 47;
} else {
newIndex -= 6 ;
} if( inputAll[newIndex] ){ inputAll[newIndex].focus(); } } //下 = 40
if(ev.keyCode == 40){ //当newIndex 在最后一行的时候 焦点要聚焦到 下一列的第一个
if(newIndex>= 48 && newIndex<53){ newIndex = (newIndex%8) + 1
}else {
newIndex += 6 ;
} if( inputAll[newIndex] ){ inputAll[newIndex].focus(); } } //左 = 37
if(ev.keyCode == 37){ newIndex -= 1 ; if( inputAll[newIndex] ){ inputAll[newIndex].focus(); }
} //右 = 39
if(ev.keyCode == 39){ newIndex += 1 ; if( inputAll[newIndex] ){ inputAll[newIndex].focus(); }
} },
注意点:
1.vue element-ui 绑定@keyup事件无效 ,加上.native覆盖原有封装的keyup事件即可
vue+elementui 中 @keyup 键盘上下左右移动聚焦的更多相关文章
- vue+element-ui中的图片获取与上传
vue+element-ui中的图片获取与上传 工作上接触了一下图片的处理,图片的格式是文件流, 记录如下. 请求图片 请求图片的时候,带上{ responseType: 'blob' }, 否则图片 ...
- vue element-ui中引入第三方icon
vue element-ui中引入第三方icon 把图标加入项目 设置项目名称,下载项目(项目名称自定义) 解压项目到开发目录 在main.js中全局引入css文件 修改下载下来的项目中的css文件, ...
- vue+elementUI中单选框el-radio设置默认值和唯一标识某个单选框
vue+elementUI中单选框el-radio设置默认值 如果后台返回的单选框的值是number:单选框的lable需要设置成 :lable='0';如下: <el-form-item la ...
- vue+element-ui中引入阿里播放器
1.在public文件下的index.html文件中插入以下代码: <link rel="stylesheet" href="https://g.alicdn.co ...
- Vue:Elementui中的Tag与页面其它元素相互交互的两三事
前言 公司系统在用elementui做后台开发,不免遇到一些需要自己去根据原有的功能上,加一些交互的功能.今天来介绍下我在用elementUi里的Tag标签与多选框交互的过程,东西听上去很简单,但就是 ...
- 关于Vue element-ui中诡异问题的解决思路
最近在做Element-ui项目时总是会出现些异步及其一些诡异问题,关于vue 的异步原理就不多说了,感觉大部分的问题都可以用Vue.nextTick来解决,Vue.nextTick是等DOM二次加载 ...
- vue element-ui 绑定@keyup事件无效
解决办法: <el-input @keyup.native="ajax"></el-input> 加上.native覆盖原有封装的keyup事件即可
- vue+element-ui中的表单验证(电话等等)
1. 2. 3. ============================================================上代码============================ ...
- Vue Element-UI 中列表单选的实现
el-table中单选的实现 引用场景: 选择单条数据进行业务操作 实现方式: 给el-table-column设置el-radio Template 代码 <div class="r ...
随机推荐
- myeclipse中使用maven插件的时候,报错-Dmaven.multiModuleProjectDirectory system propery is not set.
-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable a ...
- 【网页布局基础】css布局学习总结
三种定位机制 1.标准文档流:从上到下,从左到右输出文档内容 2.浮动 3.绝对定位 需要注意的是块级元素如div p ul 等 行级元素如span strong img input等 块级元素与行级 ...
- 四大开源协议比较:BSD、Apache、GPL、LGPL(转)
转自: 四大开源协议比较:BSD.Apache.GPL.LGPL 本文参考文献:http://www.fsf.org/licensing/licenses/ 现今存在的开源协议很多,而经过Open S ...
- web.xml中配置——解决post乱码
<!-- 解决post乱码 --> <filter> <filter-name>CharacterEncodingFilter</filter-name> ...
- 【leetcode】963. Minimum Area Rectangle II
题目如下: Given a set of points in the xy-plane, determine the minimum area of any rectangle formed from ...
- loadrunner——win7+LR11配置
一. 安装vmware虚拟机 下载安装vmware15后,可使用密钥为:CG392-4PX5J-H816Z-HYZNG-PQRG2 二. 安装win7系统 2.1下载win7镜像文件 2.2 vmwa ...
- auth 模块使用篇
from django.cintrib import auth #登录模块 只要用auth模块一旦登录 就可以在项目的任意地方用request.user 拿到当前的用户对象 再通过 request ...
- bzoj1098题解
[题意分析] 给你一张无向图,求其补图的联通块数及各个联通块大小. [解题思路] 暴搜! 然而n2会T怎么办? 仔细观察发现m远小于n2,也就是说这是一张极其稠密的补图. 这时就要用到黑科技了:flo ...
- Go语言基础:make,new, len, cap, append, delete方法
前面提到不少Go的内建函数,这篇文章学习下如何使用.. make 先拿 make 开刀,可是一开始我就进入了误区,因为我想先找到他的源码,先是发现 src/builtin/builtin.go 中 ...
- RobotFramework 切换窗口控制的用法小结
一:滚动条控制 应用场景:通过滚动条的上下,左右移动,才能让定位的元素可见.