CollapseTransition 折叠过渡
基础用法
添加展开/折叠的过渡效果
collapse-transition
collapse-transition
<template>
<tu-button @click="visible = !visible">Toggle</tu-button>
<div style="overflow: hidden; height: 210px; margin-top: 12px;">
<tu-collapse-transition>
<div v-show="visible">
<div class="collapse-box">collapse-transition</div>
<div class="collapse-box">collapse-transition</div>
</div>
</tu-collapse-transition>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const visible = ref(true)
</script>
<style>
.collapse-box {
color: #ffffff;
background-color: var(--vp-c-brand);
width: 200px;
height: 100px;
border-radius: 4px;
display: flex;
justify-content: center;
align-items: center;
}
.collapse-box:not(:last-child) {
margin-bottom: 10px;
}
</style>
展开源码
宽度过渡
使用 with-width
添加宽度过渡
<template>
<tu-button @click="visible = !visible">Toggle</tu-button>
<div style="overflow: hidden; height: 100px; margin-top: 12px;">
<tu-collapse-transition with-width>
<div v-show="visible" class="collapse-box"></div>
</tu-collapse-transition>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const visible = ref(true)
</script>
<style>
.collapse-box {
color: #ffffff;
background-color: var(--vp-c-brand);
width: 200px;
height: 100px;
}
</style>
展开源码
CollapseTransition 属性
名称 | 说明 | 类型 | 默认值 |
---|---|---|---|
with-width | 是否使用宽度过渡 | boolean | false |