为什么当验证器方法 returns 为真时会弹出错误消息一段时间?

Why does error message pops up for some time when validator method returns true?

我尝试使用 vuelidate 通过 setTimeout 方法模拟异步验证,但是当我的异步方法 returns 为真值时,错误消息会弹出一段时间然后隐藏。

有代码沙箱:https://codesandbox.io/s/angry-montalcini-suec4?fontsize=14&hidenavigation=1&theme=dark

刚刚弄明白了。无论出于何种原因,当异步方法停止执行其操作时,自定义验证 属性(在我的示例中为 'unique')瞬间设置为 false。在这一瞬间,我还注意到 $pending 在返回 false 之前也被设置为 true。所以 - 通过在你的 if 语句中结合两者,你应该能够防止你的错误消息在那一瞬间弹出。 类似于:

v-if="!$v.email.unique && !$v.email.$pending"