以下是我pullrefresh_with_tab.html页面的代码,百度了很多方法试了都没有用,求大神指导下~
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello MUI</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="../../css/mui.min.css">
<style>
html,
body {
background-color: #efeff4;
}
.mui-bar~.mui-content .mui-fullscreen {
top: 44px;
height: auto;
}
.mui-pull-top-tips {
position: absolute;
top: -20px;
left: 50%;
margin-left: -25px;
width: 40px;
height: 40px;
border-radius: 100%;
z-index: 1;
}
.mui-bar~.mui-pull-top-tips {
top: 24px;
}
.mui-pull-top-wrapper {
width: 42px;
height: 42px;
display: block;
text-align: center;
background-color: #efeff4;
border: 1px solid #ddd;
border-radius: 25px;
background-clip: padding-box;
box-shadow: 0 4px 10px #bbb;
overflow: hidden;
}
.mui-scroll-wrapper {
position: absolute;
overflow: hidden;
bottom: 0;
}
.mui-scroll {
position: absolute;
}
.mui-pull-top-tips.mui-transitioning {
-webkit-transition-duration: 200ms;
transition-duration: 200ms;
}
.mui-pull-top-tips .mui-pull-loading {
/*-webkit-backface-visibility: hidden;
-webkit-transition-duration: 400ms;
transition-duration: 400ms;*/
margin: 0;
}
.mui-pull-top-wrapper .mui-icon,
.mui-pull-top-wrapper .mui-spinner {
margin-top: 7px;
}
.mui-pull-top-wrapper .mui-icon.mui-reverse {
/*-webkit-transform: rotate(180deg) translateZ(0);*/
}
.mui-pull-bottom-tips {
text-align: center;
background-color: #efeff4;
font-size: 15px;
line-height: 40px;
color: #777;
}
.mui-pull-top-canvas {
overflow: hidden;
background-color: #fafafa;
border-radius: 40px;
box-shadow: 0 4px 10px #bbb;
width: 40px;
height: 40px;
margin: 0 auto;
}
.mui-pull-top-canvas canvas {
width: 40px;
}
.mui-slider-indicator.mui-segmented-control {
background-color: #efeff4;
}
</style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<h1 class="mui-title">选项卡切换+下拉刷新(div模式)</h1>
</header>
<div class="mui-content" id="app">
<div class="mui-slider mui-fullscreen">
<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
<div class="mui-scroll">
{{item.title}}
</a>-->
<a class="mui-control-item mui-active" href="#item1mobile">
推荐
</a>
<a class="mui-control-item" href="#item2mobile">
热点
</a>
<a class="mui-control-item" href="#item3mobile">
北京
</a>
</div>
</div>
<div id="slider" class="mui-slider-group">
<div id="item1mobile" class="mui-slider-item mui-control-content mui-scroll-wrapper mui-active">
<div class="mui-scroll">
<ul class="mui-table-view">
<li v-for="item in tuijian" class="mui-table-view-cell">
{{item.title}}
</li>
</ul>
</div>
</div>
<div id="item2mobile" class="mui-slider-item mui-control-content mui-scroll-wrapper">
<div class="mui-scroll">
<ul class="mui-table-view">
<li v-for="item in redian" class="mui-table-view-cell">
{{item.title}}
</li>
</ul>
</div>
</div>
<div id="item3mobile" class="mui-slider-item mui-control-content mui-scroll-wrapper">
<div class="mui-scroll">
<ul class="mui-table-view">
<li v-for="item in beijing" class="mui-table-view-cell">
{{item.title}}
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<script src="../../js/mui.min.js"></script>
<script src="../../js/mui.pullToRefresh.js"></script>
<script src="../../js/mui.pullToRefresh.material.js"></script>
<script src="../../js/utils/vue.js"></script>
<script src="../../js/utils/app.js"></script>
<script type="text/javascript">
mui.init();
window.onload = function() {
mui('.mui-scroll-wrapper').scroll({
deceleration: 0.0005 //flick 减速系数,系数越大,滚动速度越慢,滚动距离越小,默认值0.0006
});
};
(function($) {
//阻尼系数
var deceleration = mui.os.ios ? 0.003 : 0.0009;
$('.mui-scroll-wrapper').scroll({
bounce: false,
indicators: true, //是否显示滚动条
deceleration: deceleration
});
$.ready(function() {
newsVue.initVuePage();
document.getElementById("slider").addEventListener("swipeup", function(event) {
});
});
})(mui);
var newsVue = new Vue({
el: '#app',
data: {
tabList: [],
tuijian: [],
redian: [],
beijing: [],
isActive: false,
count: 0
},
updated: function() {
this.$nextTick(function() {
var deceleration = mui.os.ios ? 0.003 : 0.0009;
mui('.mui-scroll-wrapper').scroll({
bounce: false,
indicators: true, //是否显示滚动条
deceleration: deceleration
});
})
},
methods: {
initVuePage: function() {
console.log("AAAAAAAAA");
//循环初始化所有下拉刷新,上拉加载。
mui.each(document.querySelectorAll('.mui-slider-group .mui-scroll'), function(index, pullRefreshEl) {
mui(pullRefreshEl).pullToRefresh({
down: {
callback: function() {
var self = this;
setTimeout(function() {
newsVue.pulldownRefresh(index);
self.endPullDownToRefresh();
}, 1000);
}
},
up: {
callback: function() {
var self = this;
setTimeout(function() {
newsVue.pullupRefresh(index);
self.endPullUpToRefresh();
}, 1000);
}
}
});
});
},
/**
* 下拉刷新获取最新列表
*/
pulldownRefresh: function(index) {
newsVue.count++;
console.log(index);
if(index == 0) {
newsVue.tuijian = newsVue.createFragment();
} else if(index == 1) {
newsVue.redian = newsVue.createFragment();
} else {
newsVue.beijing = newsVue.createFragment();
}
},
/**
* 上拉加载拉取历史列表
*/
pullupRefresh: function(index) {
newsVue.count++;
console.log(index);
if(index == 0) {
newsVue.tuijian = newsVue.createFragment();
} else if(index == 1) {
newsVue.redian = newsVue.createFragment();
} else {
newsVue.beijing = newsVue.createFragment();
}
},
createFragment: function() {
var newItems = [];
for(var i = 0; i < 5 * newsVue.count; i++) {
newItems.push({
title: "第" + i + "个例子"
});
}
return newItems;
}
}
});
</script>
</body>
</html>
4 个回复
7***@qq.com (作者) - 程序员一枚
希望大神们能帮我看下,实在没辙了~谢谢大家了
l28
你好,我最近也在写这个,不太熟,能给一个demo 吗
梦尋Junjie - 原来她有男朋友
这种情况 你可以使用多个 vue 解决这一的问题 , 一个
下面说说原因:>
梦尋Junjie - 原来她有男朋友
/ vues vue:{ fans:null,follow:null } */
initVue: function() {
/* 第一个 /
friend.vueOne = new Vue({
el: "#vue-app-one",
data: {
fans: [],
},
mounted: function() {
friend.vueOne = this;
friend.p_vue_mui();
friend.fans.read();
}
});
/ 第二个 */
friend.vueTow = new Vue({
el: "#vue-app-tow",
data: {
follow: []
},
mounted: function() {
friend.vueTow = this;
friend.p_vue_mui();
friend.follow.read();
}
});
},
init_index:0,
/* 需要两个初始化完毕后在初始mui /
p_vue_mui:function(){
if(++friend.init_index>=2){
friend.initMui();
}
},
deceleration: 0,
initMui: function() {
mui.init();
friend.deceleration = mui.os.ios ? 0.003 : 0.0009;
mui('.mui-scroll-wrapper').scroll({
bounce: false,
indicators: true, //是否显示滚动条
deceleration: friend.deceleration
});
mui.each(document.querySelectorAll('.mui-slider-group .mui-scroll'), function(index, pullRefreshEl) {
mui(pullRefreshEl).pullToRefresh({
up: {
callback: function() {
var self = this;
//-> 通过 this 对象来判断执行的函数
var type = self.element.dataset.friendType;
var fri = friend[type];
if (fri) {
if (fri.noMore) {
fri.self.pullUpTipsIcon.innerText = "没有了"
} else {
fri.self = self;
fri.read();
}
} else {
self.endPullUpToRefresh();
}
}
}
});
});
},