I\'ve search for a solution and came up with this code
methods: {
handleScroll () {
console.log(window.scrollY)
}
},
created () {
window.addEventListen
window
is undefined because nuxt JS is server side rendered.
So try it using process.client
variable
methods: {
handleScroll () {
console.log(window.scrollY)
}
},
created () {
if (process.client) {
window.addEventListener('scroll', this.handleScroll);
}
},
destroyed () {
if (process.client) {
window.removeEventListener('scroll', this.handleScroll);
}
}
See link for more info