<html>
<body>
<h2>js防抖</h2>
<input placeholder="请输入电话"/>
<script>
let telInput=document.querySelector("input")
telInput.addEventListener('input',noDou(demo,1000))
//防抖封装
function noDou(fn,wait){
let timeOut=null;
return args=>{
if(timeOut) clearTimeout(timeOut)
timeOut=setTimeout(fn,wait)
}
}
function demo(){
console.log("发起请求")
}
</script>
</body>
</html>