vue js 好玩的简单的特效 可扩展的动画卡片

        

<div class="cardbox">
			<div :class="linstindex === index ? 'cad2':'cad1'" @click="cad(index)" v-for="(item,index) in list"
				:key="index" v-bind:style="{ 'background-image': 'url(' + item.img + ')', }">
			</div>
		</div>

 

<script>
	export default {
		data() {
			return {
				list: [{
						img: 'https://gd-hbimg.huaban.com/9ede6b7ffbfbcef23400e03548900d76480774abae24e-p4SdeM_fw658webp',
						cla:'run'
					},
					{
						img: 'https://gd-hbimg.huaban.com/9ede6b7ffbfbcef23400e03548900d76480774abae24e-p4SdeM_fw658webp',
						cla:'run'
					},
					{
						img: 'https://gd-hbimg.huaban.com/9ede6b7ffbfbcef23400e03548900d76480774abae24e-p4SdeM_fw658webp',
						cla:'run'
					}

				],
				linstindex: '',
				num: 0,
				
			}
		},
		mounted() {
		},
		methods: {
			
			cad(index) {
				if(this.linstindex === index){
					if (this.num % 2 != 0) {
						console.log(1)
						this.linstindex = index
					} else {
						this.linstindex = ''
						console.log(2)
					}
					// this.num++
					console.log(this.num,'num')
				}else{
					this.linstindex = index
				}
			}
		}
	}
</script>
.cardbox {
		width: 100vw;
		height: 50vh;
		display: flex;
		align-items: center;
		justify-content: center;

		.cad1 {
			width: 20vw;
			height: 40vh;
			margin-left: 2vw;
			animation-name: zun;
			animation-duration: 1s;
		}

		.cad2 {
			width: 30vw;
			height: 40vh;
			margin-left: 2vw;
			animation-name: run;
			animation-duration: 1s;
		}

		@keyframes run {
			from {
				width:20vw ;
			}

			to {
				width:30vw ;
			}

		}
		@keyframes zun {
			from {
				width:30vw ;
			}
		
			to {
				width:20vw ;
			}
		
		}

	}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值