扫码枪没回车事件,实现扫码执行录入方法
1、html代码模块
<a-input @change="inputChange" v-model="form.layers" placeholder="请输入"/>
2、封装一个js防抖方法
export function debounce(fn) {
let boun= null;
return function () {
let that = this;
if(boun!== null) clearTimeout(boun);
boun= setTimeout(() => {
fn.apply(that);
boun= null
},600);
}
}
3、引入这个方法
//按照自己创建的目录引用
import { debounce } from '@views/uwms/housing/util'
4、在方法写入这个方法
inputChange: debounce(function() {
//拿到input输入框的值
console.log(this.form.layers)
}, 1000)