VUE中自定义动画

VUE中自定义动画 动画的使用

1.首先在style中定义好动画和名字

@keyframes bounce {
        0%{
            transform: scale(0);
        }
        25%{
            transform: scale(0.2);
        }
        50%{
            transform: scale(0.4);
        }
        75%{
            transform: scale(0.8);
        }
        100%{
            transform: scale(1);
        }
  1. 在style中定义动画的完成和消失时间
 .bounce-enter-active{
        animation: bounce 1s;
    }
    .bounce-leave-active{
        animation: bounce 1s reverse;
    }

3.把对应的标签放在中,在对应的标签中绑定消失和出现的指令

<template>
    <div>
        <button @click="Btn = !Btn">点击过渡</button>
        <p></p>
        <transition name="bounce">
            <img v-if="Btn" :src="pic" alt="">
        </transition>
    </div>
</template>

<script>
    import pic from "../assets/logo.png";

    export default {
        name: "TransitionAndAnimateTwo",
        data(){
            return{
                Btn:false,
                pic:pic
            }
        }
    }
</script>

<style scoped>
    .bounce-enter-active{
        animation: bounce 1s;
    }
    .bounce-leave-active{
        animation: bounce 1s reverse;
    }

    @keyframes bounce {
        0%{
            transform: scale(0);
        }
        25%{
            transform: scale(0.2);
        }
        50%{
            transform: scale(0.4);
        }
        75%{
            transform: scale(0.8);
        }
        100%{
            transform: scale(1);
        }

    }
</style>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值