vue scroll bar event (get away from the bottom scroll bar)

Most online vue scroll bar operation is achieved dom listening, I realized with @scroll

First, there is a scroll bar div must be set a fixed height and overflow: auto; scroll bar

<div @scroll="getScroll" style="height:100px;overflow:auto;">
    <ul>
      <li>内容</li>
    </ul>
 </div>

Then the obtained distance from the bottom of the scroll bar in the process

getScroll () { 
      // distance from the bottom of the scroll bar scrollBottom 
      the let scrollBottom = 
        event.target.scrollHeight - 
        event.target.scrollTop - 
        event.target.clientHeight; 
      // IF (this.finished && scrollBottom <40) { 
      // operations 
      //} 
    },

  Well, now we get to the bottom of the scroll bar from a distance, and can be used to cook Raja upload operations or other operations of the

      What bug to welcome you to leave a message! ! Thank you

Guess you like

Origin www.cnblogs.com/yck123/p/10978941.html