zoukankan      html  css  js  c++  java
  • 仿头条新闻app,实现下拉刷新,上拉加载分页

    ---恢复内容开始---

    环境appcan

    appcan.ready(function() {
                page = 1;
                type = 0;
                searchDate = getNowTime();
                highSearch(type);
                appcan.frame.setBounce([0,1], function(type) {
                        //$("#pullstatus"+type).html(!type?"开始下拉":"开始上拖");
                    }, function(type) {
                        //$("#pullstatus"+type).html(!type?"下拉超过临界点,产生事件了!":"超过临界点,产生事件了!");
                    }, function(type) {
                        //$("#pullstatus"+type).html("松手了,产生事件了,开始更新数据!");
                        setTimeout(function() {
                            appcan.frame.resetBounce(type);
                            //$("#pullstatus"+type).html("");
                            
                            if(type==0){
                                //下拉刷新
                                page = 1;
                                highSearch(type);
                            }else if(type==1){
                                //上拉加载下一页
                                page++;
                                highSearch(type);
                            }
                        }, 1000);
                });
            });

    在ready函数中加入上面代码,page用来记录分页,type用来判断是下拉刷新还是上拉加载下一页的新闻。

    加载新闻的函数要有page属性来加载对应的分页,要有判断type的if。

    例如

    if (type == 1) {
                        $("#searchHighResult").append(str);
                        appcan.window.openToast("加载完毕", 1000, 5, 0);
                    } else {
                        $("#searchHighResult").html(str);
                        appcan.window.openToast("刷新成功", 1000, 5, 0);
                    }

    注意append和html,append是追加

  • 相关阅读:
    stone brook Introduction to Mathematical Statistics
    mongodb python
    CodesBay
    人机交互的本质是画图
    Latex模版–Review and Response Letters
    mongo with python
    OpenStack架构学习与解析
    Python类方法
    python装饰器
    java.sql.SQLException: Io 异常: Connection reset by peer: socket write error
  • 原文地址:https://www.cnblogs.com/tingfengqieyu/p/5069647.html
Copyright © 2011-2022 走看看