亚洲激情欧美色图_国产综合一区二区三区视频一区_五月婷啪啪_手机看久久_成人免费xxxxx在线视频_毛茸茸xxx多毛pics

18842388900

網(wǎng)站建設 APP開發(fā) 小程序

Article/文章

記錄成長點滴 分享您我感悟

您當前位置>首頁 > 知識 > 軟件開發(fā)

小程序開發(fā)之頁面上拉加載數(shù)據(jù)(附代碼)

發(fā)表時間:2019-05-20 08:49:55

文章來源:沈陽網(wǎng)站建設

標簽:微信小程序 php

分享:

瀏覽次數(shù):0

本篇文章給大家?guī)淼膬?nèi)容是關于小程序開發(fā)之頁面上拉加載數(shù)據(jù)(附代碼),有一定的參考價值,有需要的朋友可以參考一下,希望對你有所幫助。

需求是上拉加載數(shù)據(jù),實際就是獲取分頁數(shù)據(jù)。后臺就是正常的ajax請求分頁數(shù)據(jù),小程序部分稍復雜些,查了一些資料完成的, 但是資料的鏈接找不到了,不能放上以供參考了。

小程序頁面

涉及到數(shù)據(jù)循環(huán),下面是簡單的實例

 <view wx:for="{{array}}">     <view >{{item.name}}</view>     <view >{{item.age}}</view>  </view>
MVVM 的開發(fā)模式(例如 React, Vue),提倡把渲染和邏輯分離。簡單來說就是不要再讓 JS 直接操控 DOM,JS只需要管理狀態(tài)即可,然后再通過一種模板語法來描述狀態(tài)和界面結構的關系即可。

小程序JS部分

JS部分負責的是獲取數(shù)據(jù),以及拼接數(shù)據(jù)

Page({    /**     * 頁面的初始數(shù)據(jù)     */    data: {        array: [],        page: 1,        isReachBottom: true // 是否上拉加載    },    // 獲取數(shù)據(jù)    getList: function () {        var that = this;        wx.request({            url: 'https://xxx',            data: {                p: that.data.page            },            success: function (res) {                if (res.data.message == 'success') {                    // 獲取成功,數(shù)據(jù)追加                    var list = [];                    var count = res.data.data.length                    for (var i = 0; i < count; i++) {                        var data = {name: '', age: ''};                        data.name = res.data.data[i].name;                        data.age = res.data.data[i].age;                        list.push(data);                    }                    Array.prototype.push.apply(that.data.array, list);                制作軟件

<a href=http://www.www.gfche.com.cn target=_blank class=infotextkey>沈陽<a href=http://www.www.gfche.com.cn target=_blank class=infotextkey>軟件開發(fā)</a></a>,<a href=http://www.www.gfche.com.cn target=_blank class=infotextkey>沈陽<a href=http://www.www.gfche.com.cn target=_blank class=infotextkey>軟件公司</a></a>

that.setData({ array: that.data.array }) } else if (res.data.message == 'finish') { // 沒有數(shù)據(jù),禁止再次上拉加載 that.setData({ isReachBottom: false }) } } }) }, /** * 頁面上拉觸底事件的處理函數(shù) */ onReachBottom: function () { if (this.data.isReachBottom == true) { this.setData({ page: this.data.page + 1 }) this.getList() } }})

關于上拉觸底,還有這些特性

8701366-e7ae4d7ed6cbd292.png

以上就是小程序開發(fā)之頁面上拉加載數(shù)據(jù)(附代碼)的詳細內(nèi)容,更多請關注沈陽網(wǎng)站建設其它相關文章!

微信小程序,php

相關案例查看更多

主站蜘蛛池模板: 乌拉特前旗| 阳朔县| 南开区| 株洲县| 邹城市| 石嘴山市| 八宿县| 车致| 玛多县| 枣庄市| 邯郸市| 苍南县| 台江县| 航空| 鄢陵县| 金堂县| 铜梁县| 瓮安县| 肥西县| 齐齐哈尔市| 驻马店市| 雅江县| 南阳市| 昌都县| 界首市| 永德县| 新蔡县| 拉萨市| 鹿泉市| 涪陵区| 定边县| 交城县| 大悟县| 资中县| 贵德县| 十堰市| 保德县| 德惠市| 如皋市| 宁都县| 茶陵县|