1
我有這樣一些對象:(WordPress的聯接對象)嵌套JavaScript對象
attachment.sizes (which is an object and contains:)
.full (each contains height and width:)
.height
.width
.medium
.height
.width
.thumbnail
.height
.width
然後我還有一個目標:
props.size (which is either "full","medium" or "thumbnail")
我可以以某種方式寫類似
attachment.sizes.(props.size).height
爲了獲得高度? (當我想,沒有工作)
我覺得'attachment.sizes [props.size] .height'應該可以工作。 – jonhopkins