如需要本目录music其他文件,告诉我。
小程序 value未定义错误提示: [图片]代码: [代码]// pages/music/music.js[代码][代码]var[代码] [代码]config = require([代码][代码]'../../config.js'[代码][代码]);[代码] [代码]Page({[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]value:[代码][代码]' '[代码][代码],[代码][代码]//定义了变量 value :用来保存用户输入的查询关键字[代码][代码] [代码][代码]loading: [代码][代码]false[代码][代码],[代码][代码]//按键前的loading图标[代码][代码] [代码][代码]list: [], [代码][代码]//搜索结果[代码][代码] [代码][代码]ranks: [{[代码][代码] [代码][代码]type: 26,[代码][代码] [代码][代码]text: [代码][代码]'热歌'[代码][代码] [代码][代码]},[代码][代码] [代码][代码]{[代码][代码] [代码][代码]type: 23,[代码][代码] [代码][代码]text: [代码][代码]'销量'[代码][代码] [代码][代码]},[代码][代码] [代码][代码]{[代码][代码] [代码][代码]type: 18,[代码][代码] [代码][代码]text: [代码][代码]'民谣'[代码][代码] [代码][代码]},[代码][代码] [代码][代码]{[代码][代码] [代码][代码]type: 19,[代码][代码] [代码][代码]text: [代码][代码]'摇滚'[代码][代码] [代码][代码]},[代码][代码] [代码][代码]{[代码][代码] [代码][代码]type: 5,[代码][代码] [代码][代码]text: [代码][代码]'内地'[代码][代码] [代码][代码]},[代码][代码] [代码][代码]{[代码][代码] [代码][代码]type: 6,[代码][代码] [代码][代码]text: [代码][代码]'港台'[代码][代码] [代码][代码]},[代码][代码] [代码][代码]{[代码][代码] [代码][代码]type: 16,[代码][代码] [代码][代码]text: [代码][代码]'韩国'[代码][代码] [代码][代码]},[代码][代码] [代码][代码]{[代码][代码] [代码][代码]type: 17,[代码][代码] [代码][代码]text: [代码][代码]'日本'[代码][代码] [代码][代码]},[代码][代码] [代码][代码]{[代码][代码] [代码][代码]type: 3,[代码][代码] [代码][代码]text: [代码][代码]'欧美'[代码][代码] [代码][代码]},[代码][代码] [代码][代码]],[代码][代码] [代码][代码]},[代码][代码] [代码][代码]//保存输入的关键字[代码][代码] [代码][代码]inputing: [代码][代码]function[代码][代码](e) {[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]value: e.datail.value [代码][代码]//更新搜索关键字[代码][代码] [代码][代码]});[代码][代码] [代码][代码]},[代码][代码] [代码][代码]//立即搜索按钮[代码][代码] [代码][代码]bindSearch: [代码][代码]function[代码][代码]() {[代码][代码] [代码][代码]var[代码] [代码]self = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]loading: !self.data.loading[代码][代码] [代码][代码]});[代码][代码] [代码][代码]//开始搜索[代码][代码] [代码][代码]wx.request({[代码][代码] [代码][代码]url: config.config.searchByNameUrl,[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]keyword: self.data.value[代码][代码] [代码][代码]},[代码][代码] [代码][代码]success: [代码][代码]function[代码][代码](e) {[代码][代码] [代码][代码]if[代码] [代码](e.statusCode == 200) {[代码][代码] [代码][代码]self.setData({[代码][代码] [代码][代码]list: e.data.showapi_res_body.pagebean.contentlist,[代码][代码] [代码][代码]loading: !self.data.loading [代码][代码]//更新立即搜索按钮的loading图标[代码][代码] [代码][代码]});[代码][代码] [代码][代码]//将歌曲保存到本地缓存中[代码][代码] [代码][代码]wx.setStorageSync([代码][代码]'songlist'[代码][代码], e.data.showapi_res_body.pagebean.contentlist);[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码]})[代码]已经定义了value,却提示没有定义。应该如何解决这个问题?
2019-04-17如需本文件其他源代码,请告知我。
微信小程序错误: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);[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]});[代码][代码] [代码][代码]}[代码] [代码]})[代码]
2019-04-13