小程序“成语猜题”wx.request()获取题目并传值源码分享
作者:互联网
wx.request({
url:getApp().globalData.urlpath+"/getquestion",
data:{"qid":0},
method: "GET",
header:{'content-type': 'application/json' },
success:function(res){
//服务端返回题目跟选项
var resstr=JSON.stringify(res.data)
var resobj=JSON.parse(resstr)
console.log(resobj)
that.setData({
word1:resobj.word1,
word2:resobj.word2,
word3:resobj.word3,
word4:resobj.word4,
option1:resobj.option1,
option2:resobj.option2,
option3:resobj.option3,
option4:resobj.option4,
qid:resobj.questionid
})
}
})
更多源码关注下面
标签:request,resstr,猜题,源码,word1,word3,resobj 来源: https://blog.csdn.net/zfs1570/article/details/112353642