目錄
1、安裝 vue-particles 插件
2、在main.js檔案中全局引入
3、在 login.vue 代碼
需求:
将登入元件背景設定為 "粒子背景", 實作效果如圖:
1、安裝 vue-particles 插件
npm install vue-particles --save-dev
2、在main.js檔案中全局引入
import VueParticles from 'vue-particles'
Vue.use(VueParticles)
3、在 login.vue 代碼
添加 背景色 和 添加 <vue-particles></vue-particles> 标簽
<template>
<div class="login_container">
<vue-particles
color="#fff"
:particleOpacity="0.7"
:particlesNumber="60"
shapeType="circle"
:particleSize="4"
linesColor="#fff"
:linesWidth="1"
:lineLinked="true"
:lineOpacity="0.4"
:linesDistance="150"
:moveSpeed="2"
:hoverEffect="true"
hoverMode="grab"
:clickEffect="true"
clickMode="push"
class="lizi"
style="height:100%"
>
</vue-particles>
</div>
</template>
<script>
export default {}
</script>
<style scoped>
.login_container {
background-image: linear-gradient(-180deg, #1a1454 0%, #0e81a5 100%);
/*background-image: url("../images/bg_login.png");*/
background-repeat: no-repeat;
background-size: cover;
height: 100%;
}
</style>