creotip / vue-particles

Vue.js component for particles backgrounds ✨
http://vue-particles.netlify.com/
1.44k stars 194 forks source link

How to fix Nuxt error with SSR (Cannot read property 'getElementsByClassName' of null) #65

Closed MatteoGauthier closed 4 years ago

MatteoGauthier commented 4 years ago

I searched for an answer but i can't find anything. Here is my file nuxt.config.js

plugins: [
    {
      src: "~/plugins/vue-particles",
      ssr: false
    }
  ]

it throws the error Cannot read property 'getElementsByClassName' of null on route change.

MatteoGauthier commented 4 years ago

I fixed this by adding the mode to client

plugins: [
    {
      src: "~/plugins/vue-particles",
      mode: 'client'
    }
  ]

Problem solved, weird issue