VUE基础知识16

动画与过渡
geihub里面有个animate.css类库,有很多可以,集成三方。

<button @click="flag=!flag">切换</button>
<p></p>
<transition name="bounce">//fade就是方法名!
    <img v-if="flag" :src="pic" alt="">
</transition>
import pic from '@/assets/图片名.jpg' //导入图片,@自动到当前目录下面
data(){
    return{
        pic:pic,
        flag:true
    }
}
.bounce-enter-active{
    animation:bounce .5s;
}
.bounce-leave-active{
    animation:bounce reverse; //CSS基础比较重要!
}
@keyframes bounce{  //Js的基础知识
    0%{
        transform:scale(0);
    }
    50%{
        transform:scale(1.5);
    }
    100%{
    }
}

集成三方类库animate.css:open in terminal在终端打开,执行命令:npm install animate.css --save 它还有自己的官方文档:https://daneden.github.io/animate.css/

<button @click="flag=!flag">切换</button>
<p></p>
<transition enter-active-class = "animated tada" leave-active-class = "animated bounceOutRight" :duration="{enter:1000,leave=500}">
<!--在github的document中可以找到官方应用文档!上面的tada和animated标签组合使用!-->
<!--animate还有自己的官方文档:https://daneden.github.io/animate.css/!-->
    <img v-if="flag" :src="pic" alt="">
</transition>
import pic from '@/assets/图片名.jpg' //导入图片,@自动到当前目录下面
import animate from 'animate.css'//在Vue.js官方文档中,搜索‘#自定义过渡的类名’
data(){
    return{
        pic:pic,
        flag:true
    }
}
.bounce-enter-active{
    animation:bounce .5s;
}
.bounce-leave-active{
    animation:bounce reverse; //CSS基础比较重要!
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值