1👍
Based on some tutorial code I used, the following demonstrates how to add a listener in a Vue.js component to the scroll event and a method to do something if the user scrolls to the bottom of the window.
Note that when doing window.addEventListener
, you must remove it using window.removeEventListener
.
Maybe this can help you get started.
created: function () {
window.addEventListener('scroll', this.handleScroll)
},
destroyed: function () {
window.removeEventListener('scroll', this.handleScroll)
},
methods: {
handleScroll: function () {
this.scrollPos = document.body.scrollHeight - window.innerHeight - document.body.scrollTop;
if (document.body.scrollHeight - window.innerHeight - document.body.scrollTop == 0) {
// load more data here...
}
}
}
- [Vuejs]-Vue 1.0.4 js gives error on class binding: Uncaught TypeError: Cannot read property 'get' of undefined
- [Vuejs]-Wait till API response before changing view with Vue Router
0👍
It has nothing to do with any directive.
You need to listen to scroll event and ajax additional items when the user hits bottom of the window/container.
-3👍
All jquery components can be integrated with Vue through directives. But if you want people to help, you should provide a jsfiddle example.
- [Vuejs]-Html label radio works on desktop and emulator but not iOS Safari
- [Vuejs]-Output a Vue.js component – unknown custom element
Source:stackexchange.com