【发布时间】:2026-01-20 20:20:03
【问题描述】:
我正在尝试构建类似于https://stripe.com/radar(查看标记的付款)中的列表动画。卡片一张一张地垂直滚动。每张卡片都来自一个数组。
我已经实现了它并且工作正常。但是,动画并不流畅。看起来transition-group 中的动画名称="animate" 不起作用。
尝试了文档中的所有内容。找不到解决办法
https://jsfiddle.net/0aLfzs9u/
<div class="container" id="vue-instance">
<transition-group name="animate">
<div class="row align-items-center quote" :class="{active: key==1 }" @click="items.pop()" v-for="(item,key) in items" :key="item">
<div class="col-4 mt-3 mb-3">
<p>{{item}} Cement</p>
<small>75 bags</small>
</div>
<div class="col-7">
<p>Thrissur</p>
<small>12 hours ago</small>
</div>
<div class="col-1">
<i class="fa fa-check"></i>
</div>
</div>
</transition-group>
<p>
some footer content
</p>
</div>
var vm = new Vue({
el: '#vue-instance',
data: {
items: [1,2,3]
},
created() {
let self = this
setInterval(function() {
self.items.pop();
self.items.splice(0, 0, Math.floor((Math.random()*100)+1));
}, 2000);
}
});
.animate-enter-active,
.animate-leave-active{
transition: all 2s;
max-height: 230px;
opacity:1;
}
.animate-enter,
.animate-leave-to{
transition: all 2s;
max-height: 0px;
overflow:hidden;
}
.quote {
box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08);
border-radius: 4px;
background-color: white;
filter: blur(3px);
transform: scale(.95);
transition: all 1s;
}
.active {
filter: blur(0px);
transform: scale(1);
transition: all 1s;
}
【问题讨论】:
-
这能解决您的问题吗? jsfiddle.net/0aLfzs9u/2
-
我以前试过。这不是一个好的解决方案。因为在移动设备中,高度可能会发生变化。尝试减小宽度,它会塌陷