小z
小z
  • 发布:2016-03-06 19:55
  • 更新:2017-01-18 18:46
  • 阅读:5159

mui的顶部选项卡不向下滚动a标签失效

分类:MUI

当界面刚载入的时候选项卡里的a标签链接是无效的,

但是向下滚动一点a标签链接就好使了

没有报错,代码如下

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<script src="../../../plugin/mui/js/mui.js"></script>
<link href="../../../plugin/mui/css/mui.css" rel="stylesheet"/>
<link rel="stylesheet" href="../../../mobile/global/css/active/active.css" />
<!--下拉刷新和上拉加载-->
<script type="text/javascript" charset="UTF-8" src="../../../plugin/mui/js/mui.pullToRefresh.js" ></script>
<script type="text/javascript" src="../../../plugin/mui/js/mui.pullToRefresh.material.js"></script>
<script>

mui.init({
swipeBack: false
});
window.onload = function(){
(function($) {
$('.mui-scroll-wrapper').scroll({
indicators: true //是否显示滚动条
});
var item2 = document.getElementById('item2mobile');
var item3 = document.getElementById('item3mobile');
document.getElementById('slider').addEventListener('slide', function(e) {
if (e.detail.slideNumber === 1) {
if (item2.querySelector('.mui-loading')) {
setTimeout(function() {
//可以把传值的函数写在这里:
//item2.querySelector('.mui-scroll').innerHTML = html2;
}, 500);
}
} else if (e.detail.slideNumber === 2) {
if (item3.querySelector('.mui-loading')) {
setTimeout(function() {
//可以把传值的函数写在这里:
//item3.querySelector('.mui-scroll').innerHTML = html3;
}, 500);
}
}
});

        //阻尼系数  
        var deceleration = mui.os.ios?0.003:0.0009;  
        $('.mui-scroll-wrapper').scroll({  
            bounce: false,  
            indicators: true, //是否显示滚动条  
            deceleration:deceleration  
        });  
        $.ready(function() {  
            //循环初始化所有下拉刷新,上拉加载。  
            $.each(document.querySelectorAll('.mui-slider-group .mui-scroll'), function(index, pullRefreshEl) {  
                $(pullRefreshEl).pullToRefresh({  
                    down: {  
                        //下拉时调用此函数界面新增信息,可以将刷新信息的函数写在里面  
                        callback: function() {  
                            var self = this;  
                            setTimeout(function() {  
                                self.endPullDownToRefresh();  
                            }, 1000);  
                        }  
                    },  
                    up: {  
                        callback: function() {  
                            //上拉加载时调用此函数界面新增信息,可以将新增信息的函数写在里面  
                            var self = this;  
                            setTimeout(function() {  
                                self.endPullUpToRefresh();  
                            }, 1000);  
                        }  
                    }  
                });  
            });  
        });  
    })(mui);  
}  

</script>
<link rel="stylesheet" href="../../../../l/css/comment.css" />
</head>
<body>
<div class="page-group">
<div class="page page-current">
<header class="mui-bar mui-bar-nav">
<a class="mui-pull-left mui-icon mui-icon-arrowthinleft" href="active.html"></a>
<h1 class="mui-title">搜索结果</h1>
</header>
<div class="mui-content">
<div id="slider" class="mui-slider mui-fullscreen">
<div id="sliderSegmentedControl" class="mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
<a class="mui-control-item" href="#item1mobile">
全部
</a>
<a class="mui-control-item" href="#item2mobile">
我参与
</a>
<a class="mui-control-item" href="#item3mobile">
已结束
</a>
</div>
<div id="sliderProgressBar" class="mui-slider-progress-bar mui-col-xs-4"></div>
<div class="mui-slider-group">
<div id="item1mobile" class="mui-slider-item mui-control-content mui-active">
<div id="scroll1" class="mui-scroll-wrapper">
<div class="mui-scroll">
<ul class="mui-table-view">
<li class="mui-table-view-cell">
<a href="../active/detail.html">
<img src="../../../../resources/imgs/mobile/comment/cbd.jpg" />
<span>最新活动信息。免费学习机会</span>
<p>活动类型:学习</p>
<p>时间:2016-2-28</p>
<span class="mark bg-blue">报名中</span>
</a>
</li>
<li class="mui-table-view-cell">
<a href="../active/detail.html">
<img src="../../../../resources/imgs/mobile/comment/cbd.jpg" />
<span>最新活动信息。免费学习机会</span>
<p>活动类型:学习</p>
<p>时间:2016-2-28</p>
<span class="mark bg-red">进行中</span>
</a>
</li>
<li class="mui-table-view-cell">
<a href="../active/detail.html">
<img src="../../../../resources/imgs/mobile/comment/cbd.jpg" />
<span>最新活动信息。免费学习机会</span>
<p>活动类型:学习</p>
<p>时间:2016-2-28</p>
<span class="mark bg-green">已结束</span>
</a>
</li>
<li class="mui-table-view-cell">
<a href="../active/detail.html">
<img src="../../../../resources/imgs/mobile/comment/cbd.jpg" />
<span>最新活动信息。免费学习机会</span>
<p>活动类型:学习</p>
<p>时间:2016-2-28</p>
<span class="mark bg-green">已结束</span>
</a>
</li>
</ul>
</div>
</div>
</div>
<div id="item2mobile" class="mui-slider-item mui-control-content">
<div id="scroll2" class="mui-scroll-wrapper">
<div class="mui-scroll">
<div class="mui-loading">
<div class="mui-spinner">
</div>
</div>
</div>
</div>
</div>
<div id="item3mobile" class="mui-slider-item mui-control-content">
<div id="scroll3" class="mui-scroll-wrapper">
<div class="mui-scroll">
<div class="mui-loading">
<div class="mui-spinner">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

2016-03-06 19:55 负责人:无 分享
已邀请:
小z

小z (作者)

有人能指点一下吗...

  • 2***@qq.com

    有人弄好了吗,我也同样的问题

    2016-07-29 12:06

DCloud_UNI_FXY

DCloud_UNI_FXY

能否发一个可以直接运行的测试工程

  • 小z (作者)

    一顿测试后找到问题的大概方向了,就是在js里写下拉刷新的那个方法时,不滚动a标签就会失效,把下面这段代码去掉就好使了,虽然没弄懂没啥会影响a标签,出问题的代码是这段,去掉就好使了:

    callback: function() {

    var self = this;

    setTimeout(function() {

    self.endPullDownToRefresh();

    }, 1000);

    }

    2016-03-07 18:00

  • DCloud_UNI_FXY

    A标签事件最好都用tap事件实现

    2016-03-07 18:03

  • 小z (作者)

    回复 DCloud_UNI_FXY:好的,谢谢了,重写后确实解决了

    2016-03-07 19:15

  • 2***@qq.com

    但去掉后刷新没了

    2016-07-29 13:03

小z

小z (作者)

解决方法是自己写了套跳转,a标签的默认跳转是无效的

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