React: drop-down list scroll trigger (onPopupScroll)

Used to dynamically add option data

handleByPopupScroll = (e) => {
    let {target} = e
    //当前滚动到的位置
    let start = target.scrollTop + target.offsetHeight
    //最后的位置
    let ned = target.scrollHeight
    
    //滚动到顶部
    if(target.scrollTop == 0){
       //处理逻辑......
    }else{
        //滚动底部
        if(start == end){
           //处理逻辑.....
        }
    }
}

render(){
    return (
        <Select
            onPopupScroll={handleByPopupScroll}
        >
          {dataSource && dataSource.map(item => (
            <Select.Option  key={item.id}>{item.area}</Select.Option>
              ))
         }

        </Select>
    )
}

Dynamically display whether to load, whether to load all data

Guess you like

Origin blog.csdn.net/weixin_66709443/article/details/129789965