当前位置:网站首页>学习探索-函数防抖
学习探索-函数防抖
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)
}),
边栏推荐
- pychrm社区版调用matplotlib.pyplot.imshow()函数图像不弹出的解决方法
- R language ggplot2 visual time series histogram: visual time series histogram through two-color gradient color matching color theme
- 通俗的讲解,带你入门协程
- Interview assault 63: how to remove duplication in MySQL?
- R language ggplot2 visualization: use the ggdotplot function of ggpubr package to visualize dot plot, set the palette parameter, and set the colors of data points and box graphs of dot plots at differ
- Helm deploy etcd cluster
- Use of map (the data of the list is assigned to the form, and the JSON comma separated display assignment)
- PMP每日一练 | 考试不迷路-7.6
- AUTOCAD——中心线绘制、CAD默认线宽是多少?可以修改吗?
- A popular explanation will help you get started
猜你喜欢
Intelligent supply chain management system solution for hardware and electromechanical industry: digital intelligent supply chain "creates new blood" for traditional industries
Solution of commercial supply chain management platform for packaging industry: layout smart supply system and digitally integrate the supply chain of packaging industry
Simple understanding of MySQL database
谷粒商城--分布式高级篇P129~P339(完结)
How to improve website weight
pychrm社区版调用matplotlib.pyplot.imshow()函数图像不弹出的解决方法
倒计时2天|腾讯云消息队列数据接入平台(Data Import Platform)直播预告
Master Xuan joined hands with sunflower to remotely control enabling cloud rendering and GPU computing services
Pytorch common loss function
How word displays modification traces
随机推荐
中缀表达式转后缀表达式详细思路及代码实现
Simple understanding of MySQL database
R language ggplot2 visual time series histogram: visual time series histogram through two-color gradient color matching color theme
包装行业商业供应链管理平台解决方案:布局智慧供应体系,数字化整合包装行业供应链
C language daily practice - day 22: Zero foundation learning dynamic planning
倒计时2天|腾讯云消息队列数据接入平台(Data Import Platform)直播预告
How word displays modification traces
C # - realize serialization with Marshall class
Actf 2022 came to a successful conclusion, and 0ops team won the second consecutive championship!!
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
Use of map (the data of the list is assigned to the form, and the JSON comma separated display assignment)
Understanding disentangling in β- VAE paper reading notes
五金机电行业供应商智慧管理平台解决方案:优化供应链管理,带动企业业绩增长
Word如何显示修改痕迹
多线程基础:线程基本概念与线程的创建
R语言使用rchisq函数生成符合卡方分布的随机数、使用plot函数可视化符合卡方分布的随机数(Chi Square Distribution)
MRO industrial products enterprise procurement system: how to refine procurement collaborative management? Industrial products enterprises that want to upgrade must see!
Graffiti intelligence is listed on the dual main board in Hong Kong: market value of 11.2 billion Hong Kong, with an annual revenue of 300 million US dollars
Excel 中VBA脚本的简单应用
[matlab] Simulink the input and output variables of the same module cannot have the same name