节流函数这么声明的,在调用的时候如果method没有带参数是可以调用
$(".fundName").bind('input porpertychange', function(){
throttle(newbee, window);
})
})
function throttle(method, context) {
clearTimeout(method.tId);
method.tId = setTimeout(function () {
method.call(context);
}, 500);
}
function newbee(){
console.log(1)
}
但是如果所调用的话函数有参数传递过去,在throttle里method就显示undefined
$(document).ready(function(){
$(".fundName").bind('input porpertychange', function(){
throttle(newbee("1"), window);
})
})
function throttle(method, context) {
clearTimeout(method.tId);
method.tId = setTimeout(function () {
method.call(context);
}, 500);
}
function newbee(tar){
console.log(tar)
}
请大家指点
慕妹3146593
相关分类