下面介绍一下我自己查阅资料以及某位大佬的博文进行总结的鼠标点击特效
上源码 最主要的部分
<template>
<div>
<div id="lovesBgc" ></div>
<!-- 点击biubiubiu小心心 start-->
<div v-for="(item,index) in loves" v-bind:key="index" v-bind:ref="loves[index].count" class="img"
v-bind:style="item.top+item.left+item.scale+item.opacity">
<div class="left" v-bind:style="item.childBgc"></div>
<div class="right" v-bind:style="item.childBgc"></div>
<div class="under" v-bind:style="item.childBgc"></div>
<div class="text"> {
{text[loves[index].textIndex]}}</div>
</div>
<!-- 点击biubiubiu小心心 stop-->
<!-- 上升气泡 start-->
<div class="bubbels">
<div v-for="(item,index) in bubbles" v-bind:key="index" class="bubble"
v-bind:style="item.color+item.width+item.height+item.left+
item.delay+item.duration">
</div>
</div>
<!-- 上升气泡 stop-->
</div>
</template>
<script>
export default {
data(){
const text = ["小哥哥你好呀~", "我好喜欢你~", "我爱你~", "哎呀呀~", "mua~", "小姐姐你好呀", "想你", "咦~"];
const loves = [];
const bubbles = [];
return {
text : text, //小心心上边显示的文字
textIndex : 0, //小心心数组下标
loves : loves, //小心心样式
count : 0, //创建元素个数
bubbles : bubbles,
}
},
methods: {
// 创建小心心
createLoves(event,a,b) {//这个地方 a,b代表定位文字和小心