验证器方法返回true时,为什么错误消息会弹出一段时间?

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

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

lxd2006121146 回答:验证器方法返回true时,为什么错误消息会弹出一段时间?

只是弄清楚了这一点。无论出于何种原因,当异步方法消失时,自定义验证属性(在我的情况下为“唯一”)在瞬间就被设置为false。我还注意到,在此瞬间,$ pending也将设置为true,然后再返回false。因此-通过在if语句中将两者组合在一起,您应该能够防止错误消息突然出现。 像这样:

#include <armadillo>
typedef arma::Col<size_t> Pixel;
int nc = 256;

arma::field<Pixel> my_cube(nc,nc,nc);

for (size_t i = 0; i < nc; i++)
{
    for (size_t j = 0; j < nc; j++)
    {
        for (size_t k = 0; k < nc; k++)
        {
            Pixel px = { i,j,k };
            my_cube[i,k] = px;
            my_cube[i,k].print();  // here I get the correct value for (i,k)
        }

    }
}

my_cube[0,0].print();  // here I get (255,255,0) instead of (0,0)
// If I try my_cube(0,0).print() or my_cube.at(0,0).print()
// I get the same wrong result for the (0,0) pixel and 
// [matrix(0x1)] for different values of the indices.
本文链接:https://www.f2er.com/2807570.html

大家都在问