原代码:
wx.request({
url: configurl.getcate,
data: '',
header: {
'content-type': 'application/json' // 默认值
},
method: 'GET',
dataType: 'json',
responseType: 'text',
success: function(res) {
this.setData({
cate: res.data
})
},
fail: function(res) {},
complete: function(res) {},
})
运行结果:
修改:
var that = this;
wx.request({
url: configurl.getcate,
data: '',
header: {
'content-type': 'application/json' // 默认值
},
method: 'GET',
dataType: 'json',
responseType: 'text',
success: function(res) {
that.setData({
cate: res.data
})
},
fail: function(res) {},
complete: function(res) {},
})
即可。