当我用 Ionic 3 中表单的值覆盖我的 Condition
对象的属性时,我遇到了这种奇怪的行为。它的 value
被构造为 null
,然后被 String
覆盖。当我在覆盖后尝试访问它时,我得到 null
而不是 "8"
。这是我运行的 console.log
的图片:
这就是我尝试覆盖 value
属性的方式:
for (var property in form.value) {
if (form.value.hasOwnProperty(property)) {
var index = this.numberArray.findIndex((cond) => cond.name == property)
this.numberArray[index].value = form.value[property];
}
}
最佳答案
你应该使用严格的'==='并且看起来像是来自console.log()的延迟评估
关于Javascript 对象有一个有两个值的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44663737/