我们通过 GET 方法从 .NET 后端接收到 Google Chrome 对象
Delivery {
Id: 1,
ShippingDateTime: null,
ApproximateHandoverDateTime: null,
Charge: 527,
Cost: null
}
如果我们查看 GET 方法的预览 Delivery.Charge
是 527
。
但是如果我们输入 console.log(Delivery)
,它会显示 Delivery.Charge
是 NaN
!!!
此外,如果我们输入 console.log(Delivery.Charge)
,它将返回 527
!
这是怎么回事?请解释!
更新 即使在 GET 方法之后我仍然键入 Delivery.Charge = 123 console.log(Delivery) 给我 Delivery.Charge 作为 NaN。疯了!
最佳答案
将您的属性名称更改为“Charge”以外的任何名称。
例如,Charge -> DeliveryCharge:
Delivery {
Id: 1,
ShippingDateTime: null,
ApproximateHandoverDateTime: null,
DeliveryCharge: 527,
Cost: null
}
关于javascript - 为什么 JS 对象控制台日志给出的是 NaN 而不是 Number?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33674980/