'NuxtJS /Vue not firing scroll event

I'm using Vue3 and NuxtJS,but it seems like scroll event wont fire. Nothing happens after I scroll,nor I don't have any errors

methods: {
    handleScroll () {
      console.log('scrolled')
      }
  },
created(){
   if(process.client){
    window.addEventListener('scroll', this.handleScroll);
    console.log(window)

}
  },
  destroyed () {
    if(process.client){
    window.removeEventListener('scroll', this.handleScroll);
    }
}


Solution 1:[1]

I guess the problem is that your process.client is false.

I tried the code below and it works fine for me:

  methods: {
    handleScroll() {
      console.log("scrolled");
    },
  },
  created() {
    window.addEventListener("scroll", this.handleScroll);
    console.log(window);
  },
  destroyed() {
    window.removeEventListener("scroll", this.handleScroll);
  },
</js>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 laurisstepanovs