标签:you bsp span rgba rgb form data reac virt
for..in loops iterate over the entire prototype chain, which is virtually never what you want.
意思是使用for..in会遍历整个原型链,这样不是很好的实现方法,推荐使用Object.keys
formRules: { name: true, cardType: true, certificateNo: true }, formData: { name: ‘‘, certificateType: ‘‘, certificateNo: ‘‘ }
for (const key in this.formData) { if (!this.formData[key]) { this.formRules[key] = false; valid = false } if (this.formData[key]) this.formRules[key] = true }
Object.keys(this.formData).forEach(key => { if (!this.formData[key]) { this.formRules[key] = false; valid = false } if (this.formData[key]) this.formRules[key] = true })
for..in loops iterate over the entire prototype chain, which is virtually never what you want.
标签:you bsp span rgba rgb form data reac virt
原文地址:https://www.cnblogs.com/qianxiaoPro/p/14703064.html