Javascript 未定义描述

Javascript 未定义描述,javascript,json,ajax,Javascript,Json,Ajax,我的代码是 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

我的代码是

    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';
}
我现在不知道该做什么。我没有得到价值回报吗?有人能帮我修一下吗。我是新手,所以这可能是个愚蠢的问题。试着用第一种方法来做,因为我有更多的东西要添加,比如天气压力、风速、日出等等。

这里

function Weather(cityName, description) {
    this.cityName = cityName
    this.description = descriptions;  // <--
    this._temperature = '';
}

您编写了说明而不是说明

您在下面的代码块中有一个输入错误-

function Weather(cityName, description) {
this.cityName = cityName
this.description = descriptions;
this._temperature = '';

请将this.description=description更正为this.description=description

我在代码中没有看到任何声明为description的变量,因此description没有按字面定义: