使用函数节流之后找不到相关调用函数

节流函数这么声明的,在调用的时候如果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)

}


请大家指点


慕莱坞森
浏览 690回答 2
2回答

慕妹3146593

入参method不是一个函数,函数执行后返回 undefined
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript