有一个在控制台中打印的数组,如图所示
console.log(quote);
如何在js中访问quote.shippingAddress()latestValue[countryID]?
正如@harmandeep-singh-kalsi建议的console.log(quote.shippingAddress.subscribe(data => {data._latestValue }));
但是
quote.shippingAddress.subscribe(data => {data._latestValue.countryId });
返回错误无法读取未定义的属性“countryId”
最佳答案
你没有访问权限吗? console.log(quote.shippingAddress()['countryId']);
您的 shippingAddress
是一个 observable
,因此您需要调用它来获取“_lastestValue
”
关于javascript - 访问 Observable 数组的 _latestValue 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60355714/