网友真实露脸自拍10p,成人国产精品秘?久久久按摩,国产精品久久久久久无码不卡,成人免费区一区二区三区

小程序模板網

微信小程序加載更多,點擊查看更多

發布時間:2018-03-31 09:22 所屬欄目:小程序開發教程
感謝原作者XiaoBaiduQs,原文地址

微信小程序加載更多,是將之前的數據和點擊加載后請求的數據用concat拼接在一起并執行setData,

下面是一個簡單的栗子:

index.wxml代碼如下

 

[html] view plain copy
 
  1. <view wx:for="{{duanziInfo}}" wx:for-item="name" wx:for-index="id">   
  2.     <view class="duanzi-view">  
  3.       <view class="duanzi-content">  
  4.         <text class="dz-content">{{name.content}}</text>  
  5.       </view>  
  6.     </view>  
  7. </view>  
  8. <view class="button-wrapper">  
  9.   <button type="default" size="default" loading="{{loading}}" disabled="{{disabled}}" bindtap="setLoading">  
  10.     {{loadText}}  
  11.   </button>  
  12. </view>  
加載更多按鈕綁定setLoading

 

index.js文件代碼如下

 

[javascript] view plain copy
 
  1. Page({  
  2.         data: {  
  3.             loadText:'加載更多',  
  4.             duanziInfo:[]  
  5.         },  
  6.     //初始化請求  
  7.     onLoad: function (res) {  
  8.         var that = this  
  9.         //內容  
  10.         wx.request({  
  11.             url: 'http://xxxxx.com/index.php?m=Industry&a=getDuanziInfo',  
  12.             data: {token:token},  
  13.             method: 'GET',   
  14.             success: function(res){  
  15.             console.log(res.data.result) //打印初始化數據  
  16.                 that.setData({  
  17.                 duanziInfo:res.data.result  
  18.                 })  
  19.             }  
  20.         })  
  21.       },  
  22.       //加載更多  
  23.     setLoading: function(e) {  
  24.         var duanziInfoBefore = this.data.duanziInfo  
  25.         var that = this  
  26.         wx.showToast({ //期間為了顯示效果可以添加一個過度的彈出框提示“加載中”  
  27.             title: '加載中',  
  28.             icon: 'loading',  
  29.             duration: 200  
  30.           })  
  31.         wx.request({  
  32.             url: 'http://xxxxx.com/index.php?m=Industry&a=getDuanziInfo',  
  33.             data: {token:token},  
  34.             method: 'GET',   
  35.             success: function(res){  
  36.                 console.log(duanziInfoBefore.concat(res.data.result)) //打印拼接之后數據  
  37.                 that.setData({  
  38.                 loadText:"數據請求中",  
  39.                 loading:true,  
  40.                 duanziInfo:duanziInfoBefore.concat(res.data.result),  
  41.                 loadText:"加載更多",  
  42.                 loading:false,  
  43.               })  
  44.             }  
  45.         })  
  46.     }  
  47. })  

初始化和加載更多中的打印數據如下



易優小程序(企業版)+靈活api+前后代碼開源 碼云倉庫:starfork
本文地址:http://www.xiuhaier.com/wxmini/doc/course/22999.html 復制鏈接 如需定制請聯系易優客服咨詢:800182392 點擊咨詢
QQ在線咨詢
AI智能客服 ×