我的代码是
var data = JSON.parse(http.responseText);
var weatherData = new Weather(cityName, data);
weatherData.temperature = data.main.temp;
updateWeather(weatherData);
function Weather(cityName, data) {
this.cityName = cityName
data.weather[0].description = descriptions;
this._temperature = '';
}
function updateWeather(weatherData) {
weatherCity.textContent = weatherData.cityName;
weatherDescription.textContent = weatherData.descriptions;
weatherTemperature.textContent = weatherData.temperature;
loadingText.style.display = 'none';
weather.style.display = 'block';
}我得到的错误描述没有定义。如果我这样做,就能正常工作
var data = JSON.parse(http.responseText);
var weatherData = new Weather(cityName, data.weather[0].description);
weatherData.temperature = data.main.temp;
updateWeather(weatherData);
function Weather(cityName, description) {
this.cityName = cityName
this.description = descriptions;
this._temperature = '';
}
function updateWeather(weatherData) {
weatherCity.textContent = weatherData.cityName;
weatherDescription.textContent = weatherData.descriptions;
weatherTemperature.textContent = weatherData.temperature;
loadingText.style.display = 'none';
weather.style.display = 'block';
}我不知道现在该做什么。我没有得到返回值吗?有人能帮我修一下吗?这样我就能明白了。我是个新手,所以这可能是一个愚蠢的问题。尝试第一种方法,因为我有更多的东西要添加,比如天气压力,风速,日出等。
发布于 2017-02-08 22:48:53
在下面的代码块中有一个拼写错误-
function Weather(cityName, description) {
this.cityName = cityName
this.description = descriptions;
this._temperature = '';请将this.description = descriptions更正为this.description = description
发布于 2017-02-08 22:48:17
这里
function Weather(cityName, description) {
this.cityName = cityName
this.description = descriptions; // <--
this._temperature = '';
}你写的是descriptions而不是description
https://stackoverflow.com/questions/42116145
复制相似问题