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);
}
});
},
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/79174.html