wx.request({
url: Rooturl_3 + '/api/v1/rublesson',
data: {
'class': that.data.search
},
method: 'GET',
header: {
'content-type': 'application/json' // 默认值
},
success: function(res) {
wx.hideLoading();
if (res.data.errorCode == 1000) {
wx.showToast({
title: '输入参数错误',
duration: '3000',
})
} else if (res.data.errorCode == 999) {
wx.showToast({
title: '服务器错误',
duration: '3000',
})
} else {
// console.log(res.data);
that.setData({
'classes': res.data
})
// this.data.search = res.data.class
}
data是接口里的参数名,其中变量用class,常量需要‘ ’或者“ ”。
在success1里面最后的把需要的参数setData存入页面缓存进行渲染。