【vue3】Transition过渡组件

编程入门 行业动态 更新时间:2024-10-26 14:32:34

【vue3】Transition过渡<a href=https://www.elefans.com/category/jswz/34/1771375.html style=组件"/>

【vue3】Transition过渡组件

  • Transition 自带的内部组件
  • xxx-enter-from 开始进入过渡 0%
  • xxx-enter-active 过渡过程
  • xxx-enter-to 过渡完成 100%
  • xxx-leave-from 开始退出 0%
  • xxx-leave-active 退出过程
  • xxx-leave-to 退出完成 100%
    xxx是组件属性name的值,自定义的。我使用的是fade-box

<template><div><el-button @click="flag = !flag">change</el-button><Transition name="fade-box"><div v-if="flag" class="box"></div></Transition></div></template><script setup lang='ts'>import { ref } from 'vue'const flag = ref(false)</script>
<style scoped lang='scss'>
.box{width: 200px;height: 200px;background-color: red;
}.fade-box-enter-from{width: 0;height: 0;
}
.fade-box-enter-active{transition: all 2s ease-in-out;
}
.fade-box-enter-to{width: 200px;height: 200px;
}
.fade-box-leave-from{width: 200px;height: 200px;
}
.fade-box-leave-active{transition: all 2s ease-in-out;
}
.fade-box-leave-to{width: 0;height: 0;
}</style>

更多推荐

【vue3】Transition过渡组件

本文发布于:2023-12-06 22:30:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1669170.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:组件   Transition

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!