@官方
Cant find variable:at request fail call1. result is not defined;at App post function;at api request fail callback function 2. Can't find variable: result;at pages/home/home requestHomeData function;at api request fail callback function 后台发现好多这种错误,都是 result is not defined at api request fail callback function,但是相应的 method 里面并没有任何 result,而且我确定所有的 result 都做了空判断,官方能指点指点吗? pages/home/home requestHomeData function: [代码]requestHomeData: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]let that = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]wx.login({[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]res.code && app.post(Url.home, {city: that.data.currentCityName, code: res.code}).then(res => {[代码][代码] [代码][代码]res.data && that.handleHomeData(res.data);[代码][代码] [代码][代码]});[代码][代码] [代码][代码]}[代码][代码] [代码][代码]});[代码][代码] [代码][代码]},[代码] App post function: [代码]/**[代码][代码] [代码][代码]* 封装 post 请求为 Promise[代码][代码] [代码][代码]* @param url[代码][代码] [代码][代码]* @param data[代码][代码] [代码][代码]* @param header[代码][代码] [代码][代码]* @returns {*|Promise<any>}[代码][代码] [代码][代码]*/[代码][代码] [代码][代码]post: [代码][代码]function[代码] [代码](url, data, header = {}) {[代码][代码] [代码][代码]if[代码] [代码]([代码][代码]this[代码][代码].globalData.deviceSerialNumber) {[代码][代码] [代码][代码]header = {...header, [代码][代码]'device-serial-number'[代码][代码]: [代码][代码]this[代码][代码].globalData.deviceSerialNumber};[代码][代码] [代码][代码]}[代码][代码] [代码][代码]return[代码] [代码]url && data && [代码][代码]new[代码] [代码]Promise((resolve, reject) => {[代码][代码] [代码][代码]wx.request({[代码][代码] [代码][代码]url: url,[代码][代码] [代码][代码]method: [代码][代码]'POST'[代码][代码],[代码][代码] [代码][代码]data: data,[代码][代码] [代码][代码]header: {[代码][代码] [代码][代码]'content-type'[代码][代码]: [代码][代码]'application/json'[代码][代码], [代码][代码]// 微信默认就是[代码][代码] [代码][代码]...header[代码][代码] [代码][代码]},[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]resolve(res);[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]reject(res);[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]});[代码][代码] [代码][代码]},[代码]
2018-06-07我也碰到了,目前猜测是其他的一些请求 success 毁掉函数里面 result 是 undefined 引起的,最好是写的时候加上 null/unfined 判断
Can't find variable: result;这类错误是什么情况?小程序后台看见很多这类错误:“Can't find variable: result;at App hideLoading function;at api request fail callback function”,都是“Can't find variable”开头的,但是我这个函数里面没有result变量啊。有谁知道什么原因吗? [图片] [图片]
2018-05-24