微信小程序错误:thirdScriptError
- 当前 Bug 的表现(可附上截图) - 预期表现 - 复现路径 - 提供一个最简复现 Demo thirdScriptError:Cannot read property 'songlist' of undefined;at api request success callback function TypeError: Cannot read property 'songlist' of undefined. [图片] 这是我练习的list.js源代码: [代码]// pages/list/list.js[代码][代码]var[代码] [代码]config = require([代码][代码]'../../config.js'[代码][代码]);[代码] [代码]var[代码] [代码]formatSeconds = [代码][代码]function[代码][代码](value) {[代码][代码] [代码][代码]var[代码] [代码]time = parseFloat(value);[代码][代码] [代码][代码]var[代码] [代码]m = Math.floor(time / 60);[代码][代码] [代码][代码]var[代码] [代码]s = time - m * 60;[代码] [代码] [代码][代码]return[代码] [代码][m, s].map(formatNumber).join([代码][代码]':'[代码][代码]);[代码] [代码] [代码][代码]function[代码] [代码]FormatNumber(n) {[代码][代码] [代码][代码]n = n.toString()[代码][代码] [代码][代码]return[代码] [代码]n[1] ? n : [代码][代码]'0'[代码] [代码]+ n[代码][代码] [代码][代码]}[代码][代码]}[代码] [代码]Page({[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]board: [代码][代码]''[代码][代码],[代码][代码] [代码][代码]songlist: [],[代码][代码] [代码][代码]loading: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]},[代码][代码] [代码][代码]onLoad: [代码][代码]function[代码][代码](options) {[代码][代码] [代码][代码]var[代码] [代码]self = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]var[代码] [代码]topid = options.type;[代码] [代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]loading: [代码][代码]true[代码][代码] [代码][代码]})[代码] [代码] [代码][代码]wx: wx.request({[代码][代码] [代码][代码]url: config.config.hotUrl,[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]topid: topid[代码][代码] [代码][代码]},[代码][代码] [代码][代码]success: [代码][代码]function[代码][代码](e) {[代码][代码] [代码][代码]//var songlist=songlist;[代码][代码] [代码][代码]//var self = this;[代码][代码] [代码][代码]if[代码] [代码](e.statusCode == 200) {[代码][代码] [代码][代码]var[代码] [代码]songlist = e.data.showapi_res_body_pagebean.songlist;[代码] [代码] [代码][代码]for[代码] [代码]([代码][代码]var[代码] [代码]i = 0; i < songlist.length; i++) {[代码][代码] [代码][代码]songlist[i].seconds = formatSeconds(songlist[i].seconds);[代码][代码] [代码][代码]}[代码][代码] [代码][代码]self.setData({ [代码][代码]//估计是这里出bug[代码][代码] [代码][代码]board: e.data.showapi_res_body_pagebean.songlist[0].albumpic_big,[代码][代码] [代码][代码]songlist: songlist,[代码][代码]/** 定位?**/[代码][代码] [代码][代码]loading: [代码][代码]false[代码][代码] [代码][代码]});[代码] [代码] [代码][代码]wx.setStorageSync([代码][代码]'songlist'[代码][代码], songlist);[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]});[代码][代码] [代码][代码]}[代码] [代码]})[代码]