微信小程序错误: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); } } }); } }) |