creotip / vue-particles

Vue.js component for particles backgrounds ✨

Home Page:http://vue-particles.netlify.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any docs on how to implement in Nuxt v2+?

donPuerto opened this issue · comments

commented

Im having hard to play any documentation?

Hey, unfortunately there now docs available but its very easy to implement.
First, you add this component using your favorite package manager.
I tend to use yarn so I ran yarn add vue-particles --dev.
Then you need to create a file under projectroot/plugins I called mine vue-particles.js and it looks like this

import Vue from 'vue'
import VueParticles from 'vue-particles'

export default () => {
  Vue.use(VueParticles)
}

After that you need to register the plugin, it is important to turn off SSR for this component since it isn't compatible with it for me.
So go inside nuxt.config.js and register the plugin. This is how my one looks like:

/*
  ** Plugins to load before mounting the App
  */
  plugins: [
    '@/plugins/element-ui',
    {
      src: '@/plugins/vue-particles',
      ssr: false
    }
  ],

Then u can use it like any other component in your pages.
Example:

<template>
  <div id="app">
    <vue-particles
      color="#dedede"
      :particleOpacity="0.7"
      :particlesNumber="80"
      shapeType="circle"
      :particleSize="4"
      linesColor="#dedede"
      :linesWidth="1"
      :lineLinked="true"
      :lineOpacity="0.4"
      :linesDistance="150"
      :moveSpeed="3"
      :hoverEffect="true"
      hoverMode="grab"
      :clickEffect="true"
      clickMode="push"
    >
    </vue-particles>
    <nuxt/>
  </div>
</template>

Regards Artur