zoukankan      html  css  js  c++  java
  • iscroll实例化iscroll动态创建不能滑动


    iscroll实例化iscroll动态创建不能滑动
     
     
    newIScroll(".main")
     
    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
            <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
            <script src="zepto.js" type="text/javascript" charset="utf-8"></script>
            <script src="iscroll.js" type="text/javascript" charset="utf-8"></script>
            <style type="text/css">
                *{
                    margin:0;
                    padding:0;
                }
                html,body,#box{
                    height:100%;
                    100%;
                }
                #box{
                    display: flex;
                    flex-direction: column;
                }
                header{
                    height:50px;
                    100%;
                    line-height:50px;
                    text-align:center;
                    background:pink;
                    color:#007AFF;
                }
                footer{
                    height:50px;
                    100%;
                    line-height:50px;
                    text-align:center;
                    background:#ccc;
                    color:red;
                }
                #main{
                    flex:1;
                    overflow: hidden;
                }
            </style>
        </head>
        <body>
            <div id="box">
                <header>头部</header>
                <div id="main">
                    <div>
                    </div>
                </div>
                <footer>尾部</footer>
            </div>
            <script type="text/javascript">
            ajax()
            function ajax(){
                $.ajax({
                    url:"http://datainfo.duapp.com/shopdata/getGoods.php",
                    dataType:"jsonp",
                    success:function(data){
                        $.each(data,function(index){
                            var dl=$("<dl></dl>")
                            var dt=$("<dt></dt>")
                            var dd=$("<dd>"+data[index].goodsName+"</dd>")
                            var img=$("<img src='"+data[index].goodsListImg+"'/>")
                            dl.append(dt)
                            dl.append(dd)
                            img.on("load",function(){
                                dt.append(img)
                                myScroll.refresh()
                            })
                            $(".list").append(dl)
                        })
                    }
                });
            }
     
     
     
                        var myScroll = new IScroll("#main")
            $(".list").on("touchend",function(){
                //console.log(myScroll.y)
                if(myScroll.y>50){
                    console.log("正在刷新")
                }else if(myScroll.y<myScroll.maxScrollY-50){
                    ajax()
                }
            })
     
     
     
            </script>
        </body>
    </html>
  • 相关阅读:
    wait(),notify(),notifyAll()
    AsyncTask
    锻炼记忆力
    apache URL重写 标志表 以及 错误解决方法
    php如何判断字符串是否是字母和数字的组合
    linux 下screen 使用
    MongoDB运行状态、性能监控,分析
    批量 汉字 转 拼音方法
    mysql 数据库备份
    LINUX下 一句话添加用户并设置ROOT权限
  • 原文地址:https://www.cnblogs.com/zhangshuda/p/7640326.html
Copyright © 2011-2022 走看看