最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2016年11月29日 13:35:54   作者:XiaoBaiduQs  
這篇文章主要為大家詳細介紹了微信小程序加載更多,點擊查看更多功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了微信小程序加載更多功能實現(xiàn)的具體代碼,供大家參考,具體內容如下

微信小程序加載更多,是將之前的數(shù)據(jù)和點擊加載后請求的數(shù)據(jù)用concat拼接在一起并執(zhí)行setData,下面是一個簡單的栗子:

index.wxml代碼如下

<view wx:for="{{duanziInfo}}" wx:for-item="name" wx:for-index="id"> 
 <view class="duanzi-view"> 
 <view class="duanzi-content"> 
 <text class="dz-content">{{name.content}}</text> 
 </view> 
 </view> 
</view> 
<view class="button-wrapper"> 
 <button type="default" size="default" loading="{{loading}}" disabled="{{disabled}}" bindtap="setLoading"> 
 {{loadText}} 
 </button> 
</view> 

加載更多按鈕綁定setLoading

index.js文件代碼如下

Page({ 
 data: { 
  loadText:'加載更多', 
  duanziInfo:[] 
 }, 
 //初始化請求 
 onLoad: function (res) { 
 var that = this 
 //內容 
 wx.request({ 
  url: 'http://xxxxx.com/index.php?m=Industry&a=getDuanziInfo', 
  data: {token:token}, 
  method: 'GET', 
  success: function(res){ 
  console.log(res.data.result) //打印初始化數(shù)據(jù) 
  that.setData({ 
  duanziInfo:res.data.result 
  }) 
  } 
 }) 
 }, 
 //加載更多 
 setLoading: function(e) { 
 var duanziInfoBefore = this.data.duanziInfo 
 var that = this 
 wx.showToast({ //期間為了顯示效果可以添加一個過度的彈出框提示“加載中” 
  title: '加載中', 
  icon: 'loading', 
  duration: 200 
  }) 
 wx.request({ 
  url: 'http://xxxxx.com/index.php?m=Industry&a=getDuanziInfo', 
  data: {token:token}, 
  method: 'GET', 
  success: function(res){ 
  console.log(duanziInfoBefore.concat(res.data.result)) //打印拼接之后數(shù)據(jù) 
  that.setData({ 
  loadText:"數(shù)據(jù)請求中", 
  loading:true, 
  duanziInfo:duanziInfoBefore.concat(res.data.result), 
  loadText:"加載更多", 
  loading:false, 
  }) 
  } 
 }) 
 } 
}) 

初始化和加載更多中的打印數(shù)據(jù)如下

(以上是點擊查看更多,還可以根據(jù)距離視圖區(qū)域的距離來加載更多,具體實現(xiàn)是將視圖用<scroll-view>標簽,并給其一個固定高度,在給定參數(shù)中設置距離像素觸發(fā)事件。具體文檔:https://mp.weixin.qq.com/debug/wxadoc/dev/component/scroll-view.html?t=20161122

為大家推薦現(xiàn)在關注度比較高的微信小程序教程一篇:《微信小程序開發(fā)教程》小編為大家精心整理的,希望喜歡。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

最新評論

太白县| 荆门市| 茶陵县| 永登县| 会昌县| 宜宾县| 桂阳县| 龙南县| 临朐县| 江永县| 巴林左旗| 阿城市| 丹阳市| 鹤岗市| 中西区| 永清县| 潼南县| 怀宁县| 通辽市| 高阳县| 都江堰市| 肥城市| 镇沅| 雅安市| 奈曼旗| 会理县| 通许县| 高清| 邓州市| 额尔古纳市| 三明市| 时尚| 鲁山县| 台江县| 耒阳市| 吴旗县| 宜黄县| 余庆县| 农安县| 偃师市| 洛阳市|