2017-07-03 144 views
0

我遇到了一個我似乎無法修復的非常奇怪的問題。基本上,我正在接收一個CSV文件並將其解析爲一個JSON對象,以保存在我的redux商店中。我有解析和一切工作...或者它看起來像它正在工作,一切都編譯成一個很好的JSON對象坐在我的商店。無法訪問對象的屬性

enter image description here

當我映射的每個項目,並登錄我的組件對象也似乎看起來是正確的,我有機會獲得我需要的一切......這樣看起來。

enter image description here

的問題是,當我試圖從這些對象得到了一個未定義不管使用屬性。因此,例如console.log(weatherData[i])console.log(weatherData.keyname)我可以如上所示記錄對象。但是,當我嘗試記錄像這樣console.log(weatherData[i].capital)console.log(weatherData.keyname.capital)我得到未定義。

我不知道爲什麼會發生這種情況,現在非常失落,所以如果任何人有任何想法,請讓我知道。我也使用componentWillMount和'setTimeout'來確保在請求之前獲得所有數據,但是這並不能解決任何問題

+0

你試過'console.log(weather.data.Kabul.country)'? – randomir

+0

@randomir剛剛嘗試過,仍然沒有定義 –

+0

@BradyEdgar從第一張圖片的日誌中看到,你有一個天氣對象,在'console.log'中,所以你如何存儲這個對象,即它會是' myObj.weather'等。從你上次評論'weatherData'是變量的權利?所以你會有'console.log(weatherData.weather)'。 – loretoparisi

回答

0

剛剛發現問題,非常愚蠢,但我的對象上的鍵有雙倍引用他們周圍的問題時,試圖將目標鎖定在他們身上!不能告訴,因爲檢查和還原工具都格式化雙引號