您当前的位置: 首页 >  动画

39 制作一个显示隐藏的切换动画效果

发布时间:2021-12-06 17:31:55 ,浏览量:7

[动画] 如何利用Vue3制作动画效果
  • 制作一个显示隐藏的切换效果
  • 编写CSS样式和制作进入动画
  • 编写退出动画
  • 总结
制作一个显示隐藏的切换效果
<html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Demo03 data(){ return { isShow:false } }, methods:{ hanldClick(){ this.isShow= !this.isShow } }, template: ` 
		
willem
切换动画
` }) const vm = app.mount("#app") 0%{ transform:translateX(-100px) } 100%{ transform:translateX(50px) } } data(){ return { isShow:false } }, methods:{ hanldClick(){ this.isShow= !this.isShow } }, template: `
willem
切换动画
` }) const vm = app.mount("#app") animation: comein 1s; } @keyframes comein{ 0%{ transform:translateX(-100px) } 100%{ transform:translateX(50px) } } 0%{ transform:translateX(50px) } 100%{ transform:translateX(-100px) } }

有了comeout的关键帧CSS,然后又是一个固定写法v-leave-active。

.v-leave-active{
    animation : comeout 1s;
}

这时候你再点击按钮,就有了退出动画。

在这里插入图片描述

<html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Demo03 data(){ return { isShow:false } }, methods:{ hanldClick(){ this.isShow= !this.isShow } }, template: ` 
		
willem
切换动画
` }) const vm = app.mount("#app") animation : comeout 1s; } @keyframes comeout{ 0%{ transform:translateX(50px) } 100%{ transform:translateX(300px) } }
关注
打赏
1688896170
查看更多评论

暂无认证

  • 7浏览

    0关注

    105695博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0493s