首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >描述未定义

描述未定义
EN

Stack Overflow用户
提问于 2017-02-08 22:43:05
回答 2查看 70关注 0票数 0

我的代码是

代码语言:javascript
复制
    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';
}

我得到的错误描述没有定义。如果我这样做,就能正常工作

代码语言:javascript
复制
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';
}

我不知道现在该做什么。我没有得到返回值吗?有人能帮我修一下吗?这样我就能明白了。我是个新手,所以这可能是一个愚蠢的问题。尝试第一种方法,因为我有更多的东西要添加,比如天气压力,风速,日出等。

EN

回答 2

Stack Overflow用户

发布于 2017-02-08 22:48:53

在下面的代码块中有一个拼写错误-

代码语言:javascript
复制
function Weather(cityName, description) {
this.cityName = cityName
this.description = descriptions;
this._temperature = '';

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

票数 1
EN

Stack Overflow用户

发布于 2017-02-08 22:48:17

这里

代码语言:javascript
复制
function Weather(cityName, description) {
    this.cityName = cityName
    this.description = descriptions;  // <--
    this._temperature = '';
}

你写的是descriptions而不是description

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42116145

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档