当前位置:网站首页>《看完就懂系列》天哪!搞懂节流与防抖竟简单如斯~
《看完就懂系列》天哪!搞懂节流与防抖竟简单如斯~
2022-07-07 10:07:00 【InfoQ】
写在前面
防抖篇
*防抖小故事
*防抖逻辑图

*防抖代码实现
setTimeoutsetTimeoutsetTimeoutsetTimeoutsetTimeoutsetTimeout // 防抖初始变量
let debouncTtimeout
// 点击防抖按钮触发函数
function debounce() {
clearTimeout(debouncTtimeout)
debouncTtimeout = setTimeout(function () {
console.log("执行防抖操作啦~")
}, 3000)
}
节流篇
*节流小故事
*节流逻辑图

*节流代码实现
// 节流初始时间戳
let pastDate = new Date().valueOf()
// 点击节流按钮触发函数
function throttle() {
let nowDate = new Date().valueOf()
if (nowDate - pastDate > 3000) {
console.log('执行节流操作啦~')
pastDate = new Date().valueOf()
}
}
总结
写在后面
边栏推荐
- Swiftui swift internal skill how to perform automatic trigonometric function calculation in swift
- Rationaldmis2022 advanced programming macro program
- 108.网络安全渗透测试—[权限提升篇6]—[Windows内核溢出提权]
- 2022 年第八届“认证杯”中国高校风险管理与控制能力挑战赛
- What are the top-level domain names? How is it classified?
- Unity 贴图自动匹配材质工具 贴图自动添加到材质球工具 材质球匹配贴图工具 Substance Painter制作的贴图自动匹配材质球工具
- 问下flinkcdc2.2.0的版本,支持并发,这个并发是指多并行度吗,现在发现,mysqlcdc全
- 【最短路】Acwing1128信使:floyd最短路
- zero-shot, one-shot和few-shot
- [texture feature extraction] LBP image texture feature extraction based on MATLAB local binary mode [including Matlab source code 1931]
猜你喜欢
![[full stack plan - programming language C] basic introductory knowledge](/img/6d/555ac6b80b015e0cdfb7ef0a234f9d.png)
[full stack plan - programming language C] basic introductory knowledge

Enclosed please find. Net Maui's latest learning resources

The Oracle message permission under the local Navicat connection liunx is insufficient

Detailed explanation of debezium architecture of debezium synchronization
![[filter tracking] comparison between EKF and UKF based on MATLAB extended Kalman filter [including Matlab source code 1933]](/img/90/ef2400754cbf3771535196f6822992.jpg)
[filter tracking] comparison between EKF and UKF based on MATLAB extended Kalman filter [including Matlab source code 1933]

The running kubernetes cluster wants to adjust the network segment address of pod

【滤波跟踪】基于matlab捷联惯导仿真【含Matlab源码 1935期】

【最短路】Acwing1128信使:floyd最短路

Time bomb inside the software: 0-day log4shell is just the tip of the iceberg

Talk about SOC startup (11) kernel initialization
随机推荐
从工具升级为解决方案,有赞的新站位指向新价值
Suggestions on one-stop development of testing life
Blog moved to Zhihu
2022 年第八届“认证杯”中国高校风险管理与控制能力挑战赛
sql里,我想设置外键,为什么出现这个问题
What development models did you know during the interview? Just read this one
【系统设计】指标监控和告警系统
Swiftui swift internal skill: five skills of using opaque type in swift
Review and arrangement of HCIA
CMU15445 (Fall 2019) 之 Project#2 - Hash Table 详解
C#中在路径前加@的作用
Nuclear boat (I): when "male mothers" come into reality, can the biotechnology revolution liberate women?
Let digital manage inventory
本地navicat连接liunx下的oracle报权限不足
禁锢自己的因素,原来有这么多
Talk about SOC startup (x) kernel startup pilot knowledge
SwiftUI 4 新功能之掌握 WeatherKit 和 Swift Charts
Internet Protocol
EasyUI learn to organize notes
通过环境变量将 Pod 信息呈现给容器