鍍金池/ 問(wèn)答/Java  HTML/ 使用函數(shù)節(jié)流之后找不到相關(guān)調(diào)用函數(shù)

使用函數(shù)節(jié)流之后找不到相關(guān)調(diào)用函數(shù)

節(jié)流函數(shù)這么聲明的,在調(diào)用的時(shí)候如果method沒(méi)有帶參數(shù)是可以調(diào)用

$(".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)
}

但是如果所調(diào)用的話(huà)函數(shù)有參數(shù)傳遞過(guò)去,在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)
}

請(qǐng)大家指點(diǎn)

回答
編輯回答
熊出沒(méi)

$(document).ready(function(){

$(".fundName").bind('input porpertychange', function(){
、、
    //問(wèn)題在這里  newbee("1") 是調(diào)用函數(shù)newbee 函數(shù)沒(méi)有些返回值 默認(rèn)返回undefinde
    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)

}

2017年6月17日 08:02
編輯回答
歆久

入?yún)ethod不是一個(gè)函數(shù),函數(shù)執(zhí)行后返回 undefined

2017年12月10日 23:31