半页
半页
  • 发布:2017-07-29 10:33
  • 更新:2017-07-29 10:33
  • 阅读:1170

【求助】下拉刷新自动加载刷新网站如baidu.com怎么实现!

分类:MUI

我试了下拉刷新的代码

<body>
<!--下拉刷新容器-->
<div id="pullrefresh" class="mui-content mui-scroll-wrapper">
<div class="mui-scroll">
<!--数据列表-->
<ul class="mui-table-view mui-table-view-chevron">
<li class="mui-table-view-cell">
<a href="" class="mui-navigate-right">Item 1</a>
</li>
<li class="mui-table-view-cell">
<a href="" class="mui-navigate-right">Item 2</a>
</li>
<li class="mui-table-view-cell">
<a href="" class="mui-navigate-right">Item 3</a>
</li>
<li class="mui-table-view-cell">
<a href="" class="mui-navigate-right">Item 4</a>
</li>
<li class="mui-table-view-cell">
<a href="" class="mui-navigate-right">Item 5</a>
</li>
</ul>
</div>
</div>
<script src="../js/mui.min.js"></script>
<script>
mui.init({
pullRefresh: {
container: '#pullrefresh',
down: {
callback: pulldownRefresh
},
up: {
contentrefresh: '正在加载...',
callback: pullupRefresh
}
}
});
/**

  • 下拉刷新具体业务实现
    */
    function pulldownRefresh() {
    setTimeout(function() {
    var table = document.body.querySelector('.mui-table-view');
    var cells = document.body.querySelectorAll('.mui-table-view-cell');
    for (var i = cells.length, len = i + 3; i < len; i++) {
    var li = document.createElement('li');
    li.className = 'mui-table-view-cell';
    li.innerHTML = '<a class="mui-navigate-right">Item ' + (i + 1) + '</a>';
    //下拉刷新,新纪录插到最前面;
    table.insertBefore(li, table.firstChild);
    }
    mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed
    }, 1500);
    }
    var count = 0;
    /**
  • 上拉加载具体业务实现
    */
    function pullupRefresh() {
    setTimeout(function() {
    mui('#pullrefresh').pullRefresh().endPullupToRefresh((++count > 2)); //参数为true代表没有更多数据了。
    var table = document.body.querySelector('.mui-table-view');
    var cells = document.body.querySelectorAll('.mui-table-view-cell');
    for (var i = cells.length, len = i + 5; i < len; i++) {
    var li = document.createElement('li');
    li.className = 'mui-table-view-cell';
    li.innerHTML = '<a class="mui-navigate-right">Item ' + (i + 1) + '</a>';
    table.appendChild(li);
    }
    }, 1500);
    }
    // if (mui.os.plus) {
    // mui.plusReady(function() {
    // setTimeout(function() {
    // mui('#pullrefresh').pullRefresh().pullupLoading();
    // }, 10);
    //
    // });
    // } else {
    // mui.ready(function() {
    // mui('#pullrefresh').pullRefresh().pullupLoading();
    // });
    // }
    </script>
    </body>

下拉刷新出来的数据是这些

如果我要刷新一个网页 如www.baidu.com,下拉刷新就自动加载这个网站,要怎么做。

2017-07-29 10:33 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复