页面加载的时候出现"can not find variable loadFail"的错误,我检查了我的代码,代码中并没有定义loadFail这样的字段,那么微信又是怎么调用到这个字段的呢?
下面是我reader页面onReady方法中的代码:
onReady: function () { let self = this // 判断是否需要显示提示 let showReaderTips = wx.getStorageSync( 'show_reader_tips' ) if (showReaderTips || showReaderTips === '' ) { self.setData({ showReaderTips: true }) } else { self.setData({ showReaderTips: false }) } //读取用户设置 let localSetting = wx.getStorageSync( 'userinfo' ) || {} if (localSetting && localSetting.setting) { let userSetting = localSetting.setting self.setData({ 'allSliderValue.bright' : userSetting.reader.bright || self.data.allSliderValue.bright, 'allSliderValue.font' : userSetting.reader.fontSize || self.data.allSliderValue.font, colorStyle: self.transColorStyle(userSetting.reader.mode) || self.data.colorStyle, currentFontFamily: userSetting.reader.fontFamily || self.data.currentFontFamily }) } // 设置背景色 wx.setNavigationBarColor({ frontColor: self.data.colorStyle.styleNum == 4 ? '#ffffff' : '#000000' , backgroundColor: self.data.colorStyle.control_bg, animation: { duration: 0, timingFunc: 'easeIn' } }) }, |
下面是警告的截图:
找到原因了,小程序代码上的bug,确实存在变量引用上的问题
打印下showReaderTips 结果