1.禁止页面滚动

1.函数

  preventBackgroundScroll(e: React.WheelEvent<HTMLDivElement>){
    const target = e.currentTarget
    if ((e.deltaY < 0 && target.scrollTop <= 0) ||(e.deltaY > 0 && target.scrollHeight - target.clientHeight - target.scrollTop <= 0)) {
      e.stopPropagation()
      e.preventDefault()
  }

2.调用

  <div onWheel = {this.state.lodding ? this.preventBackgroundScroll : null}></div>

posted @ 2018-01-11 14:05  大耳朵小虎  阅读(137)  评论(1编辑  收藏  举报