dom節(jié)流與去抖
節(jié)流:throttle,用于input keyup
getValue:function(){
var principalVal=$('#principal').val();
console.log(principalVal)
},
throttle(that.getValue, null, 500, this.value);
function throttle(fn,context,delay,text){
clearTimeout(fn.timeoutId);
fn.timeoutId = setTimeout(function(){
fn.call(context,text);
},delay);
}
- throttle 等時(shí)間間隔執(zhí)行函數(shù)。
- debounce 時(shí)間間隔 t 內(nèi)若再次觸發(fā)事件,則重新計(jì)時(shí),直到停止時(shí)間大于或等于 t 才執(zhí)行函數(shù)。

浙公網(wǎng)安備 33010602011771號(hào)