php点击查看更多,微信小程序加载更多和点击查看更多功能介绍
這篇文章主要為大家詳細(xì)介紹了微信小程序加載更多,點(diǎn)擊查看更多功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了微信小程序加載更多功能實(shí)現(xiàn)的具體代碼,供大家參考,具體內(nèi)容如下
微信小程序加載更多,是將之前的數(shù)據(jù)和點(diǎn)擊加載后請求的數(shù)據(jù)用concat拼接在一起并執(zhí)行setData,下面是一個簡單的栗子:
index.wxml代碼如下
{{name.content}} {{loadText}}
加載更多按鈕綁定setLoading
index.js文件代碼如下
Page({ data: { loadText:'加載更多', duanziInfo:[] }, //初始化請求 onLoad: function (res) { var that = this //內(nèi)容 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ù)如下
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持PHP中文網(wǎng)。
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的php点击查看更多,微信小程序加载更多和点击查看更多功能介绍的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matlab中显示ycbcr图像,rgb
- 下一篇: php自定义弹窗,自定义弹窗Style样