久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      微信小程序如何從數(shù)據(jù)庫加載數(shù)據(jù)

      本篇文章介紹了微信小程序從數(shù)據(jù)庫加載真實(shí)數(shù)據(jù)的方法,主要是配置域名服務(wù)器和編寫后臺(tái)api,以及微信小程序中發(fā)送請求代碼的編寫,希望對學(xué)習(xí)小程序開發(fā)的朋友有幫助!

      微信小程序如何從數(shù)據(jù)庫加載數(shù)據(jù)

      微信小程序如何從數(shù)據(jù)庫加載數(shù)據(jù)

      微信小程序要加載網(wǎng)站數(shù)據(jù)庫里面的真實(shí)數(shù)據(jù),有一個(gè)硬性的要求,就是你的網(wǎng)站域名必須是https協(xié)議才行,要不然你第一步服務(wù)器域名配置你都通過不了,具體申請步驟大家自行去申請吧,這里我就不做過多的介紹。下面我就以加載我博客素材最新的6條數(shù)據(jù)為案例來分析,下面是詳細(xì)步驟。

      一、進(jìn)入小程序后臺(tái)配置https服務(wù)器域名

      微信小程序如何從數(shù)據(jù)庫加載數(shù)據(jù)

      二、程序中寫好調(diào)用的數(shù)據(jù),并返回json格式

      //獲取素材列表接口,該方法位于ApplicationHomeControllerWeixinController.class.php中

        public function getdownList(){     $data=M('Material')->field('id,title,path,date,down,description,view')->order('date desc')->limit(6)->select();     echo json_encode($data);   }

      三、調(diào)用數(shù)據(jù)

      因?yàn)槲业南螺d模板是在index中,所有邏輯代碼要寫在index.js中,下面是具體的代碼

      /**    * 生命周期函數(shù)--監(jiān)聽頁面加載    */   onLoad: function () {     console.log('onLoad')     var that = this     wx.request({       url: 'https://www.100txy.com/weixin/getdownlist', //真實(shí)的接口地址       data: {},       header: {         'content-type': 'application/json'       },       success: function (res) {           console.log(res.data)         that.setData({             Industry: res.data //設(shè)置數(shù)據(jù)         })         },       fail: function (err) {         console.log(err)       }     })   },

      四、在列表模板渲染數(shù)據(jù)

      進(jìn)入到index.wxml中加載數(shù)據(jù),具體代碼如下

      <view class="newsInfo">    <block wx:for="{{Industry}}" >     <view class="newsList" wx:for-index="idx"  bindtap="showDetail" id="{{item.id}}">       <view class="pic">         <image style="width:110px;height:80px;" src="https://www.100txy.com/{{item.path}}"></image>       </view>       <view class="news_title">         <text class="title_subject">{{item.title}}n</text>         <text class="title">{{item.description}}</text><text class="dianping">瀏覽 {{item.view}}  下載 {{item.down}}</text>       </view>       </view>     <view class="hr"></view>    </block> </view>

      最后效果如下:這就是我博客素材最新的6條數(shù)據(jù),該小程序源碼我已經(jīng)放到了github上了,需要的朋友可以去下載看看。

      微信小程序如何從數(shù)據(jù)庫加載數(shù)據(jù)

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)