網站首頁 學習教育 IT科技 金融知識 旅遊規劃 生活小知識 家鄉美食 養生小知識 健身運動 美容百科 遊戲知識 綜合知識
當前位置:趣知科普吧 > 綜合知識 > 

微信小程序後臺用php怎麼寫原生sql|php寫後臺程序怎麼寫

欄目: 綜合知識 / 發佈於: / 人氣:2.9W
1.微信小程序後臺用php怎麼寫原生sql

1.用到的知識點<1> wx.request 請求接口資源(微信小程序api中的發起請求部分) <2>swiper 實現輪播圖的組件 <3>wx:for 循環語句 <4>微信小程序的基礎知識2.實現原理 首先,先看一下這個請求函數 var wx.request({ url: '******', //這裏填寫你的接口路徑 header: { //這裏寫你藉口返回的數據是什麼類型,這裏就體現了微信小程序的強大,直接給你解析數據,再也不用去尋找各種方法去解析json,xml等數據了'Content-Type': 'application/json' },data: {//這裏寫你要請求的參數 x: '' ,y: '' },success: function(res) {//這裏就是請求成功後,進行一些函數操作 console.log(res.data) } }).代碼 分解圖 <1>首先上一段知乎接口數據的json格式中的開頭"date":"20161114","stories":[ {"images":["/.jpg" ],"type":0,"id":8975316,"ga_prefix":"111422","title":"小事 · 我和你們一樣" },{"images":["/.jpg" ],"type":0,"id":8977438,"ga_prefix":"111421","title":"成長嘛,誰說就意味着一定要長大了?" },<2>index.js中 Page({ data: { duration: 2000,indicatorDots: true,autoplay: true,interval: 3000,loading: false,plain: false },onLoad: function () { var that = this//不要漏了這句,很重要 wx.request({ url: '/api/4/news/latest',headers: {'Content-Type': 'application/json' },success: function (res) {//將獲取到的json數據,存在名字叫zhihu的這個數組中 that.setData({ zhihu: res.data.stories,//res代表success函數的事件對,data是固定的,stories是是上面json數據中stories }) } }) } })<3> index.wxml中//這裏邊的屬性不重要,看下邊

php寫後臺程序怎麼寫 微信小程序後臺用php怎麼寫原生sql