mui 单页面下拉刷新
<!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-pull-top-tips {
position: absolute;
top: -20px;
left: 50%;
margin-left: -25px;
width: 40px;
height: 40px;
border-radius: 100%;
z-index: 1;
}
.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-pull-top-tips.mui-transitioning {
-webkit-transition-duration: 200ms;
transition-duration: 200ms;
}
.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">mui下拉刷新</h1>
</header> <div id="slider" class="mui-slider mui-fullscreen">
<div class="mui-slider-group">
<div id="item1mobile" class="mui-slider-item mui-control-content mui-active">
<div class="mui-scroll-wrapper">
<div class="mui-scroll">
<ul class="mui-table-view">
<li class="mui-table-view-cell">
选项卡子项-1
</li>
<li class="mui-table-view-cell">
选项卡子项-2
</li>
<li class="mui-table-view-cell">
选项卡子项-3
</li>
<li class="mui-table-view-cell">
选项卡子项-4
</li>
<li class="mui-table-view-cell">
选项卡子项-5
</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>
mui.init();
(function($) {
//阻尼系数
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() {
var ul = self.element.querySelector('.mui-table-view');
ul.insertBefore(createFragment(ul, index, 10, true), ul.firstChild);
self.endPullDownToRefresh();
}, 1000);
}
},
});
});
var createFragment = function(ul, index, count, reverse) {
var length = ul.querySelectorAll('li').length;
var fragment = document.createDocumentFragment();
var li;
for (var i = 0; i < count; i++) {
li = document.createElement('li');
li.className = 'mui-table-view-cell';
li.innerHTML = '选项卡子项-' + (length + (reverse ? (count - i) : (i + 1)));
fragment.appendChild(li);
}
return fragment;
};
});
})(mui); </script>
</body> </html>
<!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>
<link rel="stylesheet" href="../css/mui.min.css" />
</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">公告1</h1>
</header>
<div class="mui-content"> <div id="slider" class="mui-slider mui-fullscreen">
<div class="mui-slider-group" id="pullrefresh">
<div id="item1mobile" class="mui-slider-item mui-control-content mui-active">
<div class="mui-scroll-wrapper">
<div class="mui-scroll">
<ul id="list" class="mui-table-view"> </ul>
</div>
</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/api.js"></script>
<script>
mui.init();
var count = 1;
(function($) {
//阻尼系数
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() {
count=1;
ajax_get_data(this,'down',1);
self.endPullDownToRefresh();
}, 1000);
}
},
up: {
contentrefresh: '正在加载...',
callback: function() {
var self = this;
setTimeout(function() {
count=count+1;
ajax_get_data(this,'up',count);
self.endPullUpToRefresh();
}, 1000);
}
},
});
});
var ajax_get_data = function(self,type,count) {
user_token = localStorage.getItem("user_token");
user_token_obj = JSON.parse(user_token);
mui.ajax(api_url + '/public/laoodao_oa/?service=Notice.get_notice_list', {
data: {
token: user_token_obj.token,
page: count
},
dataType: 'json',
type: 'get',
timeout: 10000,
crossDomain: true,
async: false,
success: function(data) {
if(data.data.code > 0) {
var str="";
var fragment = document.createDocumentFragment();
mui.each(data.data.data, function(index, item) {
//字符串拼接
str +="<a href='gonggao_xqy.html'><li class=\"mui-card\">" +
"<div class=\"zbcolor\"></div>" +
"<div class=\"mui-card-content\">" +
"<div class=\"mui-card-content-inner\">" +
"<p class=\"txtTitle\">" + item.pubdate.substring(0, 4) + "年 " + item.title + "</p>" +
"<p class=\"txtContent\">" + item.my_desc + "</p>" +
"<p class=\"txtNote\"><span class=\"mui-pull-left\">" + item.pubdate + " " + item.publisher + "</span><span class=\"mui-pull-right\"></span></p>" +
"</div>" +
"</div>"+
"</a>";
"</li>"; //fragment拼接
li = document.createElement('li');
li.className = 'mui-card';
li.innerHTML = "<a href='gonggao_xqy.html'><div class=\"zbcolor\"></div>" +
"<div class=\"mui-card-content\">" +
"<div class=\"mui-card-content-inner\">" +
"<p class=\"txtTitle\">" + item.pubdate.substring(0, 4) + "年 " + item.title + "</p>" +
"<p class=\"txtContent\">" + item.my_desc + "</p>" +
"<p class=\"txtNote\"><span class=\"mui-pull-left\">" + item.pubdate + " " + item.publisher + "</span><span class=\"mui-pull-right\"></span></p>" +
"</div>" +
"</div>"+
"</a>";
fragment.appendChild(li); });
if(type=="down")
{ var ul = document.getElementById("list");
ul.innerHTML=str;
}
if(type=="up")
{
var ul = document.getElementById("list");
ul.appendChild(fragment);
} console.log(count);
}else{
mui.toast(data.data.msg); } }
}
);
}; ajax_get_data(null,'down',1); var change_color = function() {
for(var i = 0; i < mui(".zbcolor").length; i++) {
var mod = (i % 5);
switch(mod) {
case 0:
mui(".zbcolor")[i].style.background = "#FF8F09";
break;
case 1:
mui(".zbcolor")[i].style.background = "#FD686C";
break;
case 2:
mui(".zbcolor")[i].style.background = "#F7B449";
break;
case 3:
mui(".zbcolor")[i].style.background = "#07C391";
break;
case 4:
mui(".zbcolor")[i].style.background = "#A79CCB";
break;
}
}
} }); })(mui); </script>
</body> </html>
mui 单页面下拉刷新的更多相关文章
- 解决:mui 的 选项卡 + 下拉刷新 功能,在其中嵌入 iframe 后,在 iphone 的情况下,iframe 的内容不能滚动,只显示第一屏内容。
我所遇到的情况是,使用 mui 的 选项卡 + 下拉刷新 功能时,其中有2个页面是嵌入了别的网站的页面,而别个几个是通过 ajax 加载本网站的数据.然后 在其中嵌入 iframe 后,在 iphon ...
- 使用mui.js实现下拉刷新
闲聊: 最近因公司项目需求,小颖需要写一些html5页面,方便公司IOS和Android给APP中嵌套使用,其中需要实现拉下刷新功能,其实就是调用了一下mui.js就可以啦嘻嘻,下面跟着小颖一起来看看 ...
- MUI 选项卡切换+下拉刷新动态 完整实现一例
前台最终呈现的代码 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> < ...
- Flutter 页面下拉刷新和上拉加载
flutter_easyrefresh 正如名字一样,EasyRefresh很容易就能在Flutter应用上实现下拉刷新以及上拉加载操作,它支持几乎所有的Flutter控件.它的功能与Android的 ...
- mui前端框架下拉刷新分页加载数据
前台 mui.init(); (function($) { //阻尼系数 var deceleration = mui.os.ios?0.003:0.0009; $('.mui-scroll-wrap ...
- 微信小程序之页面下拉刷新
如果需要给单个页面设置下拉刷新功能,不需要写在""window"对象里面,直接在 文件名称.json 里面设置即可 { "enablePullDownRefr ...
- mui下拉刷新上拉加载
新外卖商家端主页订单大厅页面 使用mui双webview,实现下拉刷新上拉加载 主页面: order_index.html <!doctype html> <html> < ...
- 微信小程序下拉刷新和上拉加载的实现
一: 下拉刷新 下拉刷新两个步骤就能实现. 1.在要实现下拉刷新的页面的json配置文件里面加上 "enablePullDownRefresh": true, //开启下拉刷新 & ...
- uni-app下拉刷新加载刷新数据
onPullDownRefresh监听该页面用户下拉刷新事件需要在 pages.json 里开启 enablePullDownRefresh "globalStyle": { } ...
随机推荐
- 【Firefly API文档】—— Package Distributed
http://bbs.gameres.com/forum.php?mod=viewthread&tid=219654 package distributed 这个包中主要封装了各个服务进程间进 ...
- pip运行报错Fatal error in launcher: Unable to create process using pip.exe
使用pip的时候报错Fatal error in launcher: Unable to create process using pip.exe 解决办法,升级pip python -m pip i ...
- taro 自定义 轮播图组件
1.代码 components/MySwiper/index.js /** * 轮播图组件 */ import Taro, { Component } from '@tarojs/taro'; imp ...
- struts 页面调用Action的指定方法并传递参数
如果为action配置了类,那么默认就会执行Action类的excute方法,Action类的写法三种: ① public class Action1 { public String execute( ...
- ML:交叉验证Cross-Validation
PRML中首章绪论的模型选择,提到两个方法: 1.交叉验证(Cross-Validation) 2.赤池信息准则(Akaike Information Criterion),简称:AIC. 交叉验证是 ...
- JavaScript中逻辑运算符
一.JavaScript“逻辑”运算符 很多学习 JavaScript的人,容易被 JavaScript 的逻辑运算符的运算规则搞晕.为什么呢?因为JavaScript的逻辑运算符和其他语言(比如:j ...
- 转: RabbitMQ实现中AMQP与MQTT消息收发异同
转自:http://www.cnblogs.com/lucifer1997/p/9438186.html 实现了AMQP与MQTT(至多一次)后,用多个队列以topic exchange的方式用相同交 ...
- unity, List namespace
如果要使用List,需要using System.Collections.Generic;
- 1.文件I/O
一. open()&close() #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h& ...
- Java序列化与反序列化学习(二):序列化接口说明
一.序列化类实现Serializable接口 Serializable接口没有方法,更像是个标记.有了这个标记的Class就能被序列化机制处理. ObjectOutputStream只能对Serial ...