思路使用元素外层的container的max-height来实现
<div class="select-content" :class="[isShowList?'active-list':'']">
<div class="item" v-for="(item,index) in options1" :key="index" @click="itemClick(item)">
<span :style="{color:(item.Key === crunent?'#2BA0FF':'')}">{{item.Key}}</span>
<Icon name="success" v-if="item.Key === crunent" :style="{color:(item.Key === crunent?'#2BA0FF':'')}" />
</div>
</div>
组件中正常是未打开 select-content 在某种条件触发以后 类名会加一个active-list,接下来看我们的样式 记得展开后的高度一定要足够能够撑开你的元素 尽可能的大一点 再加上我们的一些过渡动画
.select-content{
max-height: 0;
overflow: hidden;
transition: all ease-in-out .3s;
.item{
padding:0 24px ;
display: flex;
justify-content: space-between;
align-items: center;
height: 70px;
border-bottom: 2px solid #f0f0f0;
}
}
.active-list{
transition: all ease-in-out .3s;
max-height: 500px;
}