当前位置:网站首页>简单理解防抖函数
简单理解防抖函数
2022-06-12 19:31:00 【Hello^_^Monkey】
//防抖:用户触发事件过于频繁,只需要最后一次事件的操作
const inp = document.querySelector("input");
//封装一个防抖函数
inp.oninput = debounce(function () {
console.log(this.value);
}, 500);
function debounce(fn, delay) {
let t = null;
return function () {
if (t !== null) {
clearInterval(t);
}
t = setTimeout(() => {
fn.call(this);
}, delay);
};
}
边栏推荐
- 【5GC】三种SSC(Session and Service Continuity)模式介绍
- Wincc7.5 SP1 method for adjusting picture size to display resolution
- The solution of BiliBili video list name too long and incomplete display
- 设备管理-借还模块界面代码
- The execution results of i+=2 and i++ i++ under synchronized are different
- Basic structure of arithmetic unit
- ISCC2022
- Module 8 operation
- RT-Thread 模拟器 simulator 搭建 LVGL 的开发调试环境
- Research Report on the overall scale, major manufacturers, major regions, products and application segments of lifeboats in the global market in 2022
猜你喜欢

QT -- how to get the contents of selected cells in qtableview

What did 3GPP ran do in the first F2F meeting?

Promise to solve hell function calls can be used infinitely

【数字IC/FPGA】数据累加输出

Dacom G150双模耳机,为爱发声,呵护孩子听力健康成长
![[image denoising] image denoising based on regularization with matlab code](/img/d9/74f4d9cdb4bfe157ba781ec8f6a184.png)
[image denoising] image denoising based on regularization with matlab code

基于微信电子书阅读小程序毕业设计毕设作品(7)中期检查报告

数据库全量SQL分析与审计系统性能优化之旅

In 2021, the global revenue of electro-optical modulator (EOM) is about USD 360.3 million, and it is expected to reach USD 704.4 million in 2028

【图像去噪】基于各向异性滤波实现图像去噪附matlab代码
随机推荐
Liunx deploy Seata (Nacos version)
Leetcode topic [string]-344- reverse string
[notes for question brushing] line segment tree
[matrix theory & graph theory] final exam review mind map
How does Eldon's ring of the law get lune quickly? Introduction to the fastest and safest method for obtaining lune
基於分布式數據庫本身的定時備份方法
vc hacon 联合编程 GenImage3Extern WriteImage
Vue - Advanced Vue router routing (2) (replace attribute, programming route navigation, caching route components, and exclusive hooks for routes)
Wincc7.5 SP1 method for adjusting picture size to display resolution
[image denoising] image denoising based on regularization with matlab code
【图像去噪】基于正则化实现图像去噪附matlab代码
QT -- how to get the contents of selected cells in qtableview
RT-Thread 模拟器 simulator 搭建 LVGL 的开发调试环境
[SQL] MySQL query statement execution sequence analysis
3D object detection
一种灵活注入 Istio Sidecar 的方案探索
Reading small program based on wechat e-book graduation design (4) opening report
Original introduction to Jenkins' configuration options
Typescript decorator is basically used
Super heavy! Apache Hudi multimode index optimizes queries up to 30 times