Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to listen to the bottom of the scroll bar in vue

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge of "how to listen to the bottom of the scroll bar in vue". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. How to use pure js to determine whether the scroll bar is at the bottom?

Learn about a few key words first:

(1) position of scroll bar to the top: scrollTop

(2) visible area of the current window: windowHeight

(3) Total height of scroll bar content: scrollHeight

The functions that trigger snooping are:

_ window.onscroll = function () {.}

The equation at the bottom: scrollTop+windowHeight=scrollHeight

2. Main function code

Created () {_ window.onscroll = function () {/ / variable scrollTop is the distance from the top of the scroll bar var scrollTop = document.documentElement.scrollTop | | document.body.scrollTop; / / variable windowHeight is the height of the visible area var windowHeight = document.documentElement.clientHeight | | document.body.clientHeight; / / variable scrollHeight is the total height of the scroll bar var scrollHeight = document.documentElement.scrollHeight | | document.body.scrollHeight / / condition if to the bottom of the scroll bar (scrollTop+windowHeight==scrollHeight) {/ / write the function console.log for loading data in the background ("height from the top" + scrollTop+ "visual area height" + windowHeight+ "total scroll bar height" + scrollHeight);}} "how to listen to the bottom of the scroll bar in vue". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report