input 搜索如何防抖,如何处理中文输入

input 搜索如何防抖,如何处理中文输入

<div>
	<input type="text" id="ipt">
</div>

<script>
let ipt = document.getElementById('ipt');
let dbFun = debounce()
ipt.addEventListener('keyup', function (e) {
	dbFun(e.target.value);
})
function debounce() {
    let timer;
    return function (value) {
    clearTimeout(timer);
    timer = setTimeout(() =>
      {
          console.log(value)
      }, 500);
    }
}
</script>

你可能感兴趣的:(Javascript,javascript,前端,vue.js)