微信小程序方法中无法获取全局变量的数据怎么解决?
我在全局变量中定义了一个strcount
getdata: function () { var that = this; wx.request({ url: 'https://website.defond.com.cn/WeChat_zjh/HappyFarm_WEChat.aspx', data: { }, header: { "Content-Type": "applciation/json" }, method: "GET", success: function (res) { console.log(res.data); var list = that.formatData(res.data.data), reccount = res.data.recordcount; that.strcount=reccount; console.log(list,reccount); that.setData({ logs: res.data.data, strcount:reccount }) }, fail: function (err) { console.log(showRequestInfo()) }, complete: function () { } }) }, |
然后通过getdata把数据长度赋值给strcount
createSimulationData: function () { var categories = []; var data = []; var that = this; for (var i = 0; i < 8; i++) { categories.push('2017-' + that.month + '-' + (that.day + (i + 1) - 9)); data.push(that.temp + Math.random()); } return { categories: categories, data: data } }, |
但是在此方法中。我获取不到strcount 的值。
请问我该怎么做