美文网首页
小程序中请求(wx.request)报错问题

小程序中请求(wx.request)报错问题

作者: 猫晓封浪 | 来源:发表于2019-03-07 16:26 被阅读0次

    使用 wx.request 从后台取值成功不能用 that.setData({.......}) 会报错 "this.setData is not a function;at api request success callback function"


    此问题所在就是当前 this 指代不明

    必须写成 var that=this; 指代当前 app 实例后,在 wx.request 方法中使用 that.data 获取当前 app 实例中数据



    相关文章

      网友评论

          本文标题:小程序中请求(wx.request)报错问题

          本文链接:https://www.haomeiwen.com/subject/bdxhpqtx.html