当前位置:网站首页>学习探索-函数防抖
学习探索-函数防抖
2022-07-06 11:32:00 【miao_zz】
在事件被触发n秒后再执行回调,如果在这n秒内又被触发,则重新计时
utils.js
function debounce(fn, delay = 1000) {
let timer = null;
return function() {
if (timer) {
clearTimeout(timer)
}
timer = setTimeout(() => {
fn.apply(this, arguments);
}, delay)
}
}
apply
arguments
arguments 是一个对应于传递给函数的参数的类数组对象。arguments
使用案例
import utils from "@/common/js/utils.js"
<input type="text" confirm-type="search" class="infoSearch-text" @input="getInputHandle()"
:placeholder="placeholder" placeholder-style="color:#999" style="color: #fff;" />
getInputHandle: utils.debounce(function(e) {
let value = e.detail.value;
this.$emit('input', value)
}),
边栏推荐
- test about BinaryTree
- R语言ggplot2可视化:使用ggpubr包的ggviolin函数可视化小提琴图
- CPU负载很低,loadavg很高处理方法
- AIRIOT物联网平台赋能集装箱行业构建【焊接工位信息监控系统】
- 基于蝴蝶种类识别
- 业务与应用同步发展:应用现代化的策略建议
- R语言ggplot2可视化时间序列柱形图:通过双色渐变配色颜色主题可视化时间序列柱形图
- A full set of teaching materials, real questions of Android interview of 7 major manufacturers including Alibaba Kwai pinduoduo
- MRO industrial products enterprise procurement system: how to refine procurement collaborative management? Industrial products enterprises that want to upgrade must see!
- Druid 数据库连接池 详解
猜你喜欢
全套教学资料,阿里快手拼多多等7家大厂Android面试真题
Digital "new" operation and maintenance of energy industry
Reptiles have a good time. Are you full? These three bottom lines must not be touched!
五金机电行业智能供应链管理系统解决方案:数智化供应链为传统产业“造新血”
Master Xuan joined hands with sunflower to remotely control enabling cloud rendering and GPU computing services
Helm deploy etcd cluster
零基础入门PolarDB-X:搭建高可用系统并联动数据大屏
反射及在运用过程中出现的IllegalAccessException异常
Take a look at how cabloyjs workflow engine implements activiti boundary events
今日直播 | “人玑协同 未来已来”2022弘玑生态伙伴大会蓄势待发
随机推荐
Problems encountered in using RT thread component fish
RT-Thread 组件 FinSH 使用时遇到的问题
[depth first search] Ji suanke: find numbers
PMP每日一练 | 考试不迷路-7.6
[depth first search] Ji suanke: Square
10 schemes to ensure interface data security
MRO industrial products enterprise procurement system: how to refine procurement collaborative management? Industrial products enterprises that want to upgrade must see!
short i =1; I=i+1 and short i=1; Difference of i+=1
Helm deploy etcd cluster
Solution of commercial supply chain management platform for packaging industry: layout smart supply system and digitally integrate the supply chain of packaging industry
关于图像的读取及处理等
When visual studio code starts, it prompts "the code installation seems to be corrupt. Please reinstall." Solution to displaying "unsupported" information in the title bar
Mathematical knowledge -- code implementation of Gaussian elimination (elementary line transformation to solve equations)
三面蚂蚁金服成功拿到offer,Android开发社招面试经验
test about BinaryTree
Swagger2 reports an error illegal DefaultValue null for parameter type integer
R语言ggplot2可视化:使用ggpubr包的ggstripchart函数可视化分组点状条带图(dot strip plot)、设置add参数为不同水平点状条带图添加箱图
Digital "new" operation and maintenance of energy industry
包装行业商业供应链管理平台解决方案:布局智慧供应体系,数字化整合包装行业供应链
The nearest library of Qinglong panel