这是我当前的代码
for (let i = 0; i < weatherData.list.length; i += 8) {
arrTemp.push(
<div className="display-conditions">
<p className="display-conditions-item">Location : {weatherData.city.name}, {weatherData.city.country}</p>
<p className="display-conditions-item">Temperature: {kelvinToCelsius(weatherData.list[i].main.temp)} C</p>
<p className="weather-condition-container display-conditions-item">
<img className="img-fluid" alt="icon" src={`http://openweathermap.org/img/w/${weatherData.list[i].weather[0].icon}.png`} />
Weather Condition: <em>{weatherData.list[i].weather[0].description}</em>
</p>
<p className="display-conditions-item">Humidity: {weatherData.list[i].main.humidity}</p>
<p className="display-conditions-item">Wind Speed: {weatherData.list[i].wind.speed}</p>
</div>
)
}
这是我目前的使用方式:
weatherDataCondition : res.data.list.map((main,i) => (main))
但是我想这样访问它:
{weatherData.list[i].weather[0].description}