transition的高度过渡时。height有一方是auto则无效,动态获取变化后的高度重新赋值
卡片点击后高度变高:
<div>
<a-card class="at-card" v-for="(item,index) in testData" :key="index" @click="openCard(index)" :style="{height:cardFlag===index ? autoHeight :'388px'}">
/*点击高度auto*/
</a-card>
</div>
openCard(i){
if(this.cardFlag===i){
this.cardFlag=''
}else{
this.cardFlag=i
this.$nextTick(() => { //高度变化过渡需要具体高度值
const nodes = document.querySelectorAll('.at-card')
this.autoHeight = nodes[i].scrollHeight + 'px'
})
}
},