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事件 多次快速扫描会出现字符丢失的问题(已解决)