收藏
回答

报错 is not defined,如何解决?

console.log(serviceList)

打印serviceList时报错


data: {
  serviceList: []
},

getNearServices: function () {
    let that = this;
    const { latitude, longitude } = this.data;
    console.log(this.data)
    wx.cloud.callFunction({
      name: 'getService',
      data: {
        latitude,
        longitude
      },
      success: function (res) {
        console.log('getNearServices-->',res);
        that.setData({
          serviceList: res.result.list
        })
        console.log(serviceList)
      },
      fail: console.error
    })
  },

回答关注问题邀请回答
收藏

1 个回答

  • one for all
    one for all
    2019-12-28
    console.log(that.serviceList)
    2019-12-28
    赞同
    回复 4
    • Qiu (吉²)
      Qiu (吉²)
      2019-12-28
      非常感谢。但是打印结果是undefined
      2019-12-28
      回复
    • one for all
      one for all
      2019-12-28回复Qiu (吉²)
      我在外面吃火锅,回去了看看
      2019-12-28
      回复
    • Qiu (吉²)
      Qiu (吉²)
      2019-12-28回复one for all
      嗯嗯,非常感谢🙏
      2019-12-28
      回复
    • one for all
      one for all
      2019-12-28回复Qiu (吉²)
      尴尬,给你说错了,是console.log(that.data.serviceList)
      2019-12-28
      回复
登录 后发表内容
问题标签