使用validate().then()时一直走error是为什么?

ui框架为 ant-design-vue 2.2.8

下图为打印信息

下图为 this.$refs.formRef的打印信息

阅读 3.2k
3 个回答

把 this.$refs.formRef打印出来看

截图用到了 async 然后在哪里用到了await呢?

从打印出来的 error 信息来看,没有出错的 field,但是有一个 outOfDate: true,好像是什么东西超时了。既然 then() 中的东西没执行(没进入到 then),那说明之前就出错了,也就是 validate() 的时候。如果是 then() 中因为 values 没定义出错的话,err 应该是一个语法错误。

目前的信息来看是因为超时出错。具体为什么要看 validate 中是怎么写的。如果看不到 validate 的代码,那就去查文档。

如果使用 await,大概应该是

async onsubmit(e) {
    e.preventDefault();
    try {
        await this.$refs.formRef.validate();
        console.log(values);
    } catch (err) {
        console.log("error", err);
    }
}
推荐问题