看一下上次的代码,最基础的把需要实现动画的代码块放在transition组件内
<div id="app">
<transition
appear
enter-active-class="animated swing"
leave-active-class="animated bounceOutDown"
appear-class="animated swing"
:duration="3000"
>
<p v-if="show">Hello World</p>
</transition>
<button @click="toggle">切换</button>
</div>
<script>
var app=new Vue({
el:"#app",
data:{
show:true
},
methods:{
toggle:function(){
this.show=!this.show;
}
}
})
</script>
由于使用第三方库,需要使用指定class,所有要之定义class值,使用enter-active-class和leave-active-class,必须包括animated和动画名称!
animate.css官网:https://daneden.github.io/animate.css/
但是发现第一次动画不能加载,我们在transition组件能使用 appear属性 指定一个appear-class为进入时候动画效果
appear-class="animated swing"
:duration指定动画时长单位毫秒
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有