大家好我有下面的對象結構,我正在嘗試使用解構技術獲取所有內部對象的名稱但無法做到這一點,下面是對象結構 { massingType { id name } ashraeClimateZone { id name } sourceOfData { id name } ..... } 我正在做如下的解構 constructionSetData.constructionSets.forEach(item => { if ( item.ashraeClimateZone?.id === ashraeClimateZoneId && item.massingType?.id === massingTypeId && item.sourceOfData?.id === energyCodeId ) { matchedConstructionDataSet.push(item.name); const { sourceOfData: name, massingType: name, ashraeClimateZone: name } = item; // getting error here Identifier 'name' has already been declared } }); return matchedConstructionDataSet.length ? `${matchedConstructionDataSet.join(', ')}` // here i need to use above names coming from three inner objects : 'No construction set found with the current criteria';任何人都可以讓我知道我怎樣才能實現這個解決方案,非常感謝!
解構具有相同名稱屬性的內部對象
慕勒3428872
2023-05-25 16:49:43