2018-12-10

 0

基于onscroll事件实现的loadmore(es6)

FUNC

`loadmore(e) {

  let element = e.target;

  try {

    e.stopPropagation();

  } catch (ex) {

  }

  let clientHeight = element.clientHeight; //可视区域高度

  let scrollTop = element.scrollTop;  //滚动条滚动高度

  let scrollHeight = element.scrollHeight; //滚动内容高度

  if (scrollTop > 0 && (clientHeight + scrollTop) >= scrollHeight) { //如果滚动到底部

    this.getlist('more');

  }

}

`

HTML

              onScroll={this.loadmore}>

你可能感兴趣的:(2018-12-10)