小程序如何面向对象编程
- 需求的场景描述(希望解决的问题)
Page({ onload(){let app = getApp()let that = this let customer = new customer(app ,that )}})function customer(app,indexPage){ this.app= app this.api= '//api地址 this.appid= ''//appid // this.indexPage = indexPage}customer.prototype.login=function(){ let result ={} let thatt = this let url = this.api + "地址" let form_data = {} wx.login({ success: function (res) { let client_code = res.code wx.request({ url: url, data: { app_id: thatt.appid, client_code: client_code, scene: '101', }, method: 'POST', success: function (res) { if (res.data.status == 'success') { result=res.data.data console.log(result) // thatt.indexPage.setData({ login_info: res.data.data }) } else { systemAlert(res.data.info); } }, fail: function (res) { systemAlert(res.errMsg); } }) }, fail: function (res) { systemAlert('登陆失败'); } })} |
为什么这个时候我登陆成功以后为什么不能用thi.setData({})
