当前位置:网站首页>学习探索-函数防抖
学习探索-函数防抖
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)
}),
边栏推荐
- A full set of teaching materials, real questions of Android interview of 7 major manufacturers including Alibaba Kwai pinduoduo
- R语言使用rchisq函数生成符合卡方分布的随机数、使用plot函数可视化符合卡方分布的随机数(Chi Square Distribution)
- swagger2报错Illegal DefaultValue null for parameter type integer
- 【论文笔记】TransUNet: Transformers Make StrongEncoders for Medical Image Segmentation
- Cereals Mall - Distributed Advanced p129~p339 (end)
- Countdown 2 days | live broadcast preview of Tencent cloud message queue data import platform
- Is not a drawable (color or path): the vector graph downloaded externally cannot be called when it is put into mipmap, and the calling error program crashes
- The list of people who passed the fifth phase of personal ability certification assessment was published
- spark基础-scala
- Solution of intelligent management platform for suppliers in hardware and electromechanical industry: optimize supply chain management and drive enterprise performance growth
猜你喜欢
Benefit a lot, Android interview questions
五金机电行业供应商智慧管理平台解决方案:优化供应链管理,带动企业业绩增长
快速幂模板求逆元,逆元的作用以及例题【第20届上海大学程序设计联赛夏季赛】排列计数
IC设计流程中需要使用到的文件
Abstract classes and abstract methods
MRO工业品企业采购系统:如何精细化采购协同管理?想要升级的工业品企业必看!
多线程基础:线程基本概念与线程的创建
Don't miss this underestimated movie because of controversy!
倒计时2天|腾讯云消息队列数据接入平台(Data Import Platform)直播预告
反射及在运用过程中出现的IllegalAccessException异常
随机推荐
受益匪浅,安卓面试问题
Use map function and split function to type multiple elements in one line
Characteristic colleges and universities, jointly build Netease Industrial College
swagger2报错Illegal DefaultValue null for parameter type integer
Wx applet learning notes day01
Help improve the professional quality of safety talents | the first stage of personal ability certification and assessment has been successfully completed!
Php+redis realizes the function of canceling orders over time
Reflection and illegalaccessexception exception during application
short i =1; i=i+1与short i=1; i+=1的区别
C language daily practice - day 22: Zero foundation learning dynamic planning
数学知识——高斯消元(初等行变换解方程组)代码实现
PMP每日一练 | 考试不迷路-7.6
zabbix 代理服务器 与 zabbix-snmp 监控
Interview assault 63: how to remove duplication in MySQL?
R language ggplot2 visualization: use ggviolin function of ggpubr package to visualize violin diagram
R语言使用order函数对dataframe数据进行排序、基于单个字段(变量)进行降序排序(DESCENDING)
R语言ggplot2可视化:使用ggpubr包的ggdotplot函数可视化点阵图(dot plot)、设置palette参数设置不同水平点阵图数据点和箱图的颜色
R语言使用dt函数生成t分布密度函数数据、使用plot函数可视化t分布密度函数数据(t Distribution)
The second day of rhcsa study
倒计时2天|腾讯云消息队列数据接入平台(Data Import Platform)直播预告