登录页背景特效设置(vue3使用particles.vue3)

登录页背景特效设置(vue3使用particles.vue3)

官网地址 particles.vue3

https://www.npmjs.com/package/particles.vue3

安装

npm i particles.vue3
npm i tsparticles 

使用

//在main.js中引用particles.Vue3
import {
  createApp
} from 'vue'
import Particles from 'particles.vue3'

const app = createApp(App)
app.use(Particles).mount('#app')
//login.vue中使用
<template>
  <div class="login">
    <vue-particles id="tsparticles" :particlesInit="particlesInit" :particlesLoaded="particlesLoaded" :options="{
    	fpsLimit: 60,
      interactivity: {
        detectsOn: 'canvas',
        events: {
          onClick: { // 开启鼠标点击的效果
            enable: true,
            mode: 'push'
          },
          onHover: { // 开启鼠标悬浮的效果(线条跟着鼠标移动)
            enable: true,
            mode: 'grab'
          },
          resize: true
        },
        modes: { // 配置动画效果
          bubble: {
            distance: 400,
            duration: 2,
            opacity: 0.8,
            size: 40
          },
          push: {
            quantity: 4
          },
          grab: {
            distance: 200,
            duration: 0.4
          },
          attract: { // 鼠标悬浮时,集中于一点,鼠标移开时释放产生涟漪效果
            distance: 200,
            duration: 0.4,
            factor: 5
          }
        }
      },
      particles: {
        color: {
          value: '#6AECFF' // 粒子点的颜色
        },
        links: {
          color: '#6AECFF', // 线条颜色
          distance: 150,
          enable: true,
          opacity: 0.5, // 不透明度
          width: 2   // 线条宽度
        },
        collisions: {
          enable: true
        },
        move: {
          attract: { enable: false, rotateX: 600, rotateY: 1200 },
          bounce: false,
          direction: 'none',
          enable: true,
          out_mode: 'out',
          random: false,
          speed: 1, // 移动速度
          straight: false
        },
        number: {
          density: {
            enable: true,
            value_area: 800
          },
          value: 80
        },
        opacity: {
          value: 0.5
        },
        shape: {
          type: 'circle'
        },
        size: {
          random: true,
          value: 5
        }
      },
      detectRetina: true
    }" />
  </div>
</template>

<script setup>
import { loadFull } from "tsparticles";
const particlesInit = async engine => {
  await loadFull(engine);
};

const particlesLoaded = async container => {
  console.log("Particles container loaded", container);
};
</script>

<style lang="scss" scoped>
.login{
  width: 100vw;
  height: 100vh;
  background-color: #1e9fff;
}
</style>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值