1
我想使用lodash debounce()函數。這是最簡單的例子。_.debounce不按預期工作
var update_from = function (name) {
console.log(name);
};
$(document).ready(function() {
_.debounce(update_from, 1500)("first");
_.debounce(update_from, 1500)('second');
_.debounce(update_from, 1500)("third");
});
我希望只有「第三」被打印到控制檯。但是,所有三個都印刷。
我在做什麼錯誤或誤解?根據這個article,這應該像我期望的那樣工作,但事實並非如此。
這裏是plunkr與例如:http://plnkr.co/edit/OCDAChkMes97XcMLJSag?p=preview
謝謝。那就對了。我想我需要去睡覺 – Aldarund
@Aldarund :-)當然,我自己在那裏。 –