vue3+Element-Plus+js 解决表格按住上下左右获取焦点

问题:

        一个el-table表格里面每一个框框都是一个el-input 然后给输入框v-model绑定值,绑定完成之后我们会发现有这么一个问题,不能按住上下左右键盘来移动,这时候我们操作就来了,效果如下:

 步骤走起:代码不做解释,开发时间久了就懂了

import { nextTick } from 'vue'
export class DirectionKey {
    constructor(str, code) {
        let _that = this
        str.split('_').forEach(item => {
            let o = item.split('=')
            _that[o[0]] = o[1]
        })
        if (code === 38) {
            this.previousLine()
        }
        if (code === 40) {
            this.nextLine()
        }
        if (code === 39) {
            this.next()
        }
        if (code === 37) {
            this.previous()
        }
    }
    next(x = this.x, y = this.y) {
        this.move({ x: ++x, y })
    }

    previous(x = this.x, y = this.y) {
        this.move({ x: --x, y })
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值