angular 表单重置状态
this.validateForm.reset() for (const key in this.validateForm.controls) { this.validateForm.controls[key].markAsPristine() this.validateForm.controls[key].updateValueAndValidity() }
markAsPristine()是将表单控件值标记为未改变,这个方法主要用在表单重置时、updateValueAndValidity()是重新计算表单控件的值和验证状态等。
- 上一篇 »jQuery重置form表单的方法
- 下一篇 »Vue+ElementUI重置表单数据至初始值