5***@qq.com
5***@qq.com
  • 发布:2017-03-13 17:20
  • 更新:2017-03-13 17:20
  • 阅读:1010

为什么真机和模拟器下下拉刷新都失效?

分类:MUI

<!doctype html>
<html>

<head>  
    <meta charset="UTF-8">  
    <title>Hello Mui</title>  
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />  
    <meta name="apple-mobile-web-app-capable" content="yes">  
    <!--“apple-mobile-web-app-status-bar-style”作用是控制状态栏显示样式-->  
    <meta name="apple-mobile-web-app-status-bar-style" content="black">  
    <link href="css/mui.min.css" rel="stylesheet" />  
</head>  

<body>  

     <!--下拉刷新容器-->  
     <div id="pullrefresh" class="mui-content mui-scroll-wrapper">  
       <div class="mui-scroll">  
         <!--数据列表-->  
         <ul class="mui-table-view mui-table-view-chevron">  

         </ul>  
       </div>  
     </div>  
    <script src="js/mui.min.js"></script>  
    <script type="text/javascript">  
        mui.init({  
            pullRefresh:{  
                //(容器、下拉刷新配置、上拉显示更多配置)  
                container:'#pullrefresh',   
                down:{  
                    callback: pulldownRefresh   //下拉刷新时的回调函数  
                },  
                up:{  
                    contentrefresh:'正在加载...',   //上拉刷新的文字  
                    callback:pullupRefresh      //上拉刷新的回调函数  
                }  
            }  
        });  

        mui.init({  
            pullRefresh: {  
                container: '#pullrefresh',  
                down: {  
                    callback: pulldownRefresh  
                },  
                up: {  
                    contentrefresh: '正在加载...',  
                    callback: pullupRefresh  
                }  
            }  
        });  

        //下拉刷新的具体业务实现  
        function pulldownRefresh(){  
            //模拟数据(setTimeout:在指定时间内调用函数)  
            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);  
                }  

                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();  
            },1500)  
        }  
        var count = 0;  
        //上拉加载具体业务实现  
        function pullupRefresh(){  
            setTimeout(function(){  
                mui('#pullrefresh').pullRefresh().endPullupToRefresh((++count > 2));  
                var table = document.body.querySelector('.mui-table-view');  
                var cells = document.body.querySelectorAll('.mui-table-view-cell');  
                for(var i= cells.length,len= i + 20; 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);  
                }   
            }, 2000);  
        }  
        if (mui.os.plus)  
        {  
            mui.plusReady(function(){  
                setTimeout(function(){  
                    mui('#pullrefresh').pullRefresh().pullupLoading();  
                }, 1500)  
            });  
        }else{  
            mui.ready(function(){  
                mui('#pullrefresh').pullRefresh().pullupLoading();  
            });  
        }  

    </script>  
</body>  

</html>

2017-03-13 17:20 负责人:无 分享
已邀请:

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