100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > Vue+Element ui input输入框 扫码枪触发 enter事件 多次快速扫描会出现字符丢失

Vue+Element ui input输入框 扫码枪触发 enter事件 多次快速扫描会出现字符丢失

时间:2022-02-11 07:50:41

相关推荐

Vue+Element ui input输入框 扫码枪触发 enter事件 多次快速扫描会出现字符丢失

input输入框,扫码枪触发 enter事件,多次快速扫描 第二次字符会丢失

修改之前代码:

在接口返回过来值之后,将input框值清空掉

这样写用键盘enter键快速触发多次,也不会有任何问题,但是使用扫码枪快速扫描,字符就会出现丢失现象

修改后代码:

赋完值后,就清空掉。

因为由于服务器运行过慢,接口返回结果需要时间,如果按照之前的思路,接口返回过来值之后,再清空输入框,这时,扫码枪多次扫描,就会有问题。

正确代码:

getInput() {this.queryParams = {code: this.barcode,name: this.pageOrderName,};this.barcode = "";operatePos(this.queryParams).then((res) => {this.name = "";if (res.code == 0) {// 开启自动播放this.audio.autoplay = true;this.audio.src = this.successUrl;this.sonList = res.data;this.resSize = this.sonList.platsize;this.$infoMsg.showInfoMsg(res.msg, this);} else {// 开启自动播放this.audio.autoplay = true;this.audio.src = this.errorUrl;this.$infoMsg.showErrorMsg(res.msg, this);}});},

Vue+Element ui input输入框 扫码枪触发 enter事件 多次快速扫描会出现字符丢失的问题(已解决)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。