收藏
回答

thirdScriptError


我获取和风天气原先是V5可以获取到,现在升级为S6,修改后就报错        

VM2445:1 thirdScriptError

Cannot read property 'tmp' of undefined


getWeather: function (city) {

var that = this

var url = "https://free-api.heweather.com/s6/weather"

var params = {

city: city,

key: "894fc2a749104d679fa022c3e71afe83"

}

wx.request({

url: url,

data: params,

success: function (res) {

var tmp = res.data.HeWeather6[0].now.tmp;

var txt = res.data.HeWeather6[0].now.cond.txt;

var code = res.data.HeWeather6[0].now.cond.code;

var qlty = res.data.HeWeather6[0].aqi.city.qlty;

var dir = res.data.HeWeather6[0].now.wind.dir;

var sc = res.data.HeWeather6[0].now.wind.sc;

var hum = res.data.HeWeather6[0].now.hum;

var fl = res.data.HeWeather6[0].now.fl;

var daily_forecast = res.data.HeWeather6[0].daily_forecast;

that.setData({

tmp: tmp,

txt: txt,

code: code,

qlty: qlty,

dir: dir,

sc: sc,

hum: hum,

fl: fl,

daily_forecast: daily_forecast

})

},

fail: function (res) { },

complete: function (res) { },

})

}


最后一次编辑于  2018-12-31
回答关注问题邀请回答
收藏

4 个回答

  • 禾店短剧系统
    禾店短剧系统
    2021-05-27

    来人啊😂

    2021-05-27
    有用 1
    回复
  • 2019-01-24

    这根本就是js的基础问题,百度搜索javascript的this问题,看完回来感谢我!

    2019-01-24
    有用
    回复
  • 卢霄霄
    卢霄霄
    2018-12-31

    res.data.HeWeather6[0].now 是个 undefined

    2018-12-31
    有用
    回复 17
    • .
      .
      2018-12-31

      能告诉我怎么修改吗?


      2018-12-31
      回复
    • 卢霄霄
      卢霄霄
      2018-12-31回复.

      打印下res.data.HeWeather6[0] 和 res.data.HeWeather6[0].now 呢

      2018-12-31
      回复
    • .
      .
      2018-12-31回复卢霄霄

      小白,能告诉我怎么写打印res.data.HeWeather6[0] 和 res.data.HeWeather6[0].now 

      2018-12-31
      回复
    • 卢霄霄
      卢霄霄
      2018-12-31回复.

      console.log

      2018-12-31
      回复
    • .
      .
      2018-12-31回复卢霄霄

      没啥用啊

      2018-12-31
      回复
    查看更多(12)
  • .
    .
    2018-12-31

    大家帮忙解答下,感谢

    2018-12-31
    有用
    回复
登录 后发表内容