當前位置:生活全書館 >

綜合知識

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

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

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
  • 文章版權屬於文章作者所有,轉載請註明 https://shqsg.com/zonghezhishi/6yl4n3.html