【发布时间】:2021-12-08 19:48:13
【问题描述】:
animation-iteration-count 仅在动画中应用眨眼(有时),这发生在我的项目中,并且在应用此属性时出现在 vue3 的官方文档示例中。
我做了这些测试来举例说明
.a {
width: 100px;
height: 100px;
background-color: red;
position: relative;
animation: example 1s 3;
}
@keyframes example {
0% {
transform: scale(0);
}
50% {
transform: scale(1.5);
}
100% {
transform: scale(1);
}
}
<h1>CSS Animation</h1>
<p>The animation-iteration-count property specifies the number of times an animation should run. The following example will run the animation n times before it stops:</p>
<div class="a"></div>
const app = Vue.createApp({
el: '#app',
data: function () {
return {
show: true
}
},
})
app.mount('#app')
.a {
width: 100px;
height: 100px;
background-color: red;
position: relative;
}
@keyframes example {
0% {
transform: scale(0);
}
50% {
transform: scale(1.5);
}
100% {
transform: scale(1);
}
}
.example-enter-active {
animation: example 0.5s;
animation-iteration-count: 3;
}
.example-leave-active {
animation: example .5s reverse;
}
<script src="https://unpkg.com/vue@3.0.0-rc.5/dist/vue.global.prod.js"></script>
<div id="app">
<h1>CSS Animation</h1>
<p>The animation-iteration-count property specifies the number of times an animation should run. The following example will run the animation n times before it stops:</p>
<button v-on:click="show=!show">{{show}}</button>
<transition appear name="example">
<div v-if="show" class="a"></div>
</transition>
</div>
我不知道我是否遗漏了 vuejs3 文档中的任何细节 你有什么特殊的方式来处理这个属性吗? 知道会发生什么吗?
【问题讨论】:
-
如果我不明白你的问题,每次转换之间的闪烁来自:0% { transform: scale(0); }
标签: css vue.js css-animations vuejs3