這篇文章主要介紹微信小程序中request請(qǐng)求后臺(tái)接口php的示例分析,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
微信小程序request請(qǐng)求后臺(tái)接口php的實(shí)例詳解
后臺(tái)php接口:http://www.vueyun.com/good/info
沒有處理數(shù)據(jù),直接返回了,具體再根據(jù)返回格式處理
public function getGoodInfo(Request $request) { $goods_datas = $this->Resource->get(); return response()->json(['status' => 'success','code' => 200,'message' => '獲取成功','data'=>$goods_datas]); }
小程序index.js文件中 onLoad
onLoad: function () { console.log('onLoad') wx.request({ //上線接口地址要是https測(cè)試可以使用http接口方式 url: 'http://www.vueyun.com/good/info', data: {}, method: 'GET', header: { 'content-type': 'application/json' }, success: function (res) { that.setData({ goodslist: res.data.data }); console.log(res.data.data, 1111111); }, }) },
wxml文件,
{{item.img_title}} ¥ {{item.good_price}}
以上是“微信小程序中request請(qǐng)求后臺(tái)接口php的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!