我试图在调整窗口大小时触发事件,似乎它不起作用。
$(window).resize(function(){
_.debounce(function(){
console.log("hello");
}, 100);
})
答案 0 :(得分:3)
它实际上在他们的lodash文档中显示为lodash#debounce:
$(window).on('resize', _.debounce(function() {
console.log('resized!');
}, 100));

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script>
&#13;
答案 1 :(得分:0)
香草JS:
window.onresize = _.debounce(() => {
console.log('resized!')
}, 100)