angular异步验证防抖踩坑实录(2)

/** * 初始化表单 */ initForm() { this.modifyPasswordForm = this.fb.group({ oldPassword: [null, [Validators.required], [this.userService.oldPasswordValidator()]], newPassword: [null, Validators.required], confirmNewPassword: [null, Validators.required] // updateOn 作用是在什么时候更新表单数据 // https://angular.cn/guide/form-validation#note-on-performance }, {updateOn: 'blur'}, ); }

想了解更多updateOn的内容,可查看这篇文章

总结

这次的问题可以完全说出在了看文档不仔细,神奇的是看了几遍那个StackOverflow上的回答都没发现他比我多了一个first(),虽然因此浪费了不少的时间,但收获也是巨大的,这波不亏。

好了,以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对脚本之家的支持。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/56f530fe20e5bbe26843e8ff39ce04f7.html