Vue 3 + Vite 做登錄背景動態(tài)顆粒圖用法

# 第一步: 下載 cnpm install particles.vue3 tsparticles

# 第二步: 在 main.js 文件里面 引入 import Particles from 'particles.vue3' app.use(Particles)

# 第三步: 在登錄頁面 div 里面放入 <Particles id="tsparticles" class="login-particles" :particlesInit="particlesInit" :particlesLoaded="particlesLoaded" :options="options" />

# 然后在 script 里面 引入 import { loadFull } from "tsparticles"; import {options} from '../../utils/particles'

## // 背景顆粒

const particlesInit = async (engine) => {

await loadFull(engine);

};

## // 背景顆粒

const particlesLoaded = async (container) => {

console.log("Particles container loaded", container);

};



新建文件 particles 放屬性的

export const options = {

background: {

color: {

value: '#000' // 粒子顏色

}

},

fpsLimit: 60,

interactivity: {

events: {

onClick: {

enable: true,

mode: 'push' // 可用的 click 模式有: "push", "remove", "repulse", "bubble"。

},

onHover: {

enable: true,

mode: 'grab' // 可用的 hover 模式有: "grab", "repulse", "bubble"。

},

resize: true

},

modes: {

bubble: {

distance: 400,

duration: 2,

opacity: 0.8,

size: 40

},

push: {

quantity: 4

},

repulse: {

distance: 200,

duration: 0.4

}

}

},

particles: {

color: {

value: '#ffffff'

},

links: {

color: '#ffffff', // '#dedede'。線條顏色。

distance: 150, // 線條長度

enable: true, // 是否有線條

opacity: 0.5, // 線條透明度。

width: 1 // 線條寬度。

},

collisions: {

enable: false

},

move: {

direction: 'none',

enable: true,

outMode: 'bounce',

random: false,

speed: 4, // 粒子運(yùn)動速度。

straight: false

},

number: {

density: {

enable: true,

area: 800

},

value: 80 // 粒子數(shù)量。

},

opacity: {

value: 0.5 // 粒子透明度。

},

shape: {

type: 'circle' // 可用的粒子外觀類型有:"circle","edge","triangle", "polygon","star"

},

size: {

random: true,

value: 5

}

},

detectRetina: true

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容