main.js中
Vue.directive('throttle', {
bind: (el, binding) => {
let throttleTime = binding.value; // 防抖时间
if (!throttleTime) { // 用户若不设置防抖时间,则默认2s
throttleTime = 2000;
}
let cbFun;
el.addEventListener('click', event => {
if (!cbFun) { // 第一次执行
cbFun = setTimeout(() => {
cbFun = null;
}, throttleTime);
} else {
event && event.stopImmediatePropagation();
}
}, true);
},
});
使用
<div @click="sayhello" v-throttle>提交</div>
实现效果,控制台2秒输出一次






![2023年中国胆道镜市场规模及行业现状,一次性胆道镜市场初具规模[图]](https://img-blog.csdnimg.cn/img_convert/bea8ceb3d4521f6e1825f765cc7e45aa.png)


![NginxWebUI runCmd 远程命令执行漏洞复现 [附POC]](https://img-blog.csdnimg.cn/51874564b6624f5c8dc00e6a50d9675b.png)









![NSSCTF[SWPUCTF 2021 新生赛]hardrce(无字母RCE)](https://img-blog.csdnimg.cn/52a7022091104d55a4018486f67c6e8e.png)
