Jquery 重复监听 - ythy/blog GitHub Wiki
setPagerListenerAndPlugins(pagerData:LBSearchStoreListResultInfo):void{
$(document).on('click', '#lastPage', null, ():void=>{
this.onSearch(pagerData.startIndex - this.mPageSize);
});
}
上述方法setPagerListenerAndPlugins执行多次后, 每次Click都会触发监听及onSearch多次.
正确做法是先清除监听:
setPagerListenerAndPlugins(pagerData:LBSearchStoreListResultInfo):void{
$(document).off('click', '#lastPage');
$(document).on('click', '#lastPage', null, ():void=>{
this.onSearch(pagerData.startIndex - this.mPageSize);
});
}