<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <script src="https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.js"></script> </head> <body> <div class="fang" style="height: 500px;width: 500px;background: bisque;" ></div> <script> let fang = document.querySelector('.fang') //定义好函数 function clickfang(){ console.log(111) } // 使用lodash 防抖调用 fang.addEventListener('click', _.debounce(clickfang, 500)) </script> <!-- _.debounce(func, [wait=0], [options=]) --> </body> </html>
标签:function,防抖,clickfang,lodash,fang,使用 From: https://www.cnblogs.com/xm666/p/17829270.html