【发布时间】:2018-11-09 20:54:19
【问题描述】:
我正在研究如何在错误答案时重新设置抖动动画。或者正确答案上的 Flash 动画。
我将 2 个布尔值定义为正确答案的状态,并且我知道如果我输入相同的错误答案,错误的 flash 将保持为 false。但是我该如何解决抖动动画在另一个时间启动的问题。
我做了一个小提琴,正确的代码是'1234'。当您第一次输入失败时,摇动动画就会启动。正确答案也是如此。动画仅在第一次显示。
当给出正确或错误答案时,如何再次调用动画。
<div class="alert alert-danger animated"
v-bind:class="{ 'shake': incorrect }"
v-if="incorrect">
Code is incorrect
</div>
https://jsfiddle.net/mrklein/05sfmuc2/
new Vue({
el: "#app",
data: {
correct: false,
incorrect: false,
code: '1234',
modelcode: '',
},
methods: {
checkpwd: function(todo){
if (this.modelcode == this.code) {
this.correct = true;
this.incorrect = false;
} else {
this.correct = false;
this.incorrect = true;
}
}
}
}
);
【问题讨论】:
-
我看到你正在使用 animate.css 和 vue.js。我建议您考虑使用 Vue 转换 vuejs.org/v2/guide/transitions.html 和 github.com/asika32764/vue2-animate,因为您必须在代码逻辑中保持动画状态。
标签: vue.js animate.css