请大神解答。做一个app的首页,最上面的是slider,中间是图文mui-table-view mui-grid-view,最下面想用上拉加载pullrefresh,但真机调试发现js生成的每个li元素不会换行,都挤在一行里,上拉加载的功能是好的。请问如何解决?
代码如下:
<!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.css">
<style>
html,body {
background-color: #efeff4;
}
header.mui-bar{
display: none;
}
.mui-bar-nav~.mui-content{
padding: 0;
}
.mui-table-view.mui-grid-view .mui-table-view-cell .mui-media-body{
font-size: 14px;
margin-top:0px;
color: #333;
}
</style>
</head>
<body>
<!--banner幻灯片-->
<div class="mui-content">
<div id="slider" class="mui-slider">
<div class="mui-slider-group mui-slider-loop">
<!-- 额外增加的一个节点(循环轮播:第一个节点是最后一张轮播) -->
<div class="mui-slider-item mui-slider-item-duplicate">
<a href="#">
<img src="images/yuantiao.jpg">
</a>
</div>
<!-- 第一张 -->
<div class="mui-slider-item">
<a href="#">
<img src="images/shuijiao.jpg">
</a>
</div>
<!-- 第二张 -->
<div class="mui-slider-item">
<a href="#">
<img src="images/muwu.jpg">
</a>
</div>
<!-- 第三张 -->
<div class="mui-slider-item">
<a href="#">
<img src="images/cbd.jpg">
</a>
</div>
<!-- 第四张 -->
<div class="mui-slider-item">
<a href="#">
<img src="images/yuantiao.jpg">
</a>
</div>
<!-- 额外增加的一个节点(循环轮播:最后一个节点是第一张轮播) -->
<div class="mui-slider-item mui-slider-item-duplicate">
<a href="#">
<img src="images/shuijiao.jpg">
</a>
</div>
</div>
<div class="mui-slider-indicator">
<div class="mui-indicator mui-active"></div>
<div class="mui-indicator"></div>
<div class="mui-indicator"></div>
<div class="mui-indicator"></div>
</div>
</div>
</div>
<!--banner幻灯片结束-->
<!--分类列表开始-->
<div class="mui-content" style="background-color:#fff">
<ul class="mui-table-view mui-grid-view">
<li class="mui-table-view-cell mui-media mui-col-xs-0-5">
</li>
<li class="mui-table-view-cell mui-media mui-col-xs-2-5">
<img class="mui-media-object" src="images/list_xiushi.jpg">
</li>
<li class="mui-table-view-cell mui-media mui-col-xs-0-5">
</li>
<li class="mui-table-view-cell mui-media mui-col-xs-0-5">
</li>
<li class="mui-table-view-cell mui-media mui-col-xs-2-5">
<a href="#">
<img class="mui-media-object" src="images/keqian.jpg">
<div class="mui-media-body">课前教育</div></a></li>
<li class="mui-table-view-cell mui-media mui-col-xs-0-5">
</li>
<li class="mui-table-view-cell mui-media mui-col-xs-0-5">
</li>
<li class="mui-table-view-cell mui-media mui-col-xs-2-5">
<a href="#">
<img class="mui-media-object" src="images/waiyu.jpg">
<div class="mui-media-body">外语培训</div></a></li>
<li class="mui-table-view-cell mui-media mui-col-xs-0-5">
</li>
<li class="mui-table-view-cell mui-media mui-col-xs-0-5">
</li>
<li class="mui-table-view-cell mui-media mui-col-xs-2-5">
<img class="mui-media-object" src="images/list_xiushi.jpg">
</li>
<li class="mui-table-view-cell mui-media mui-col-xs-0-5">
</li>
<br>
<li class="mui-table-view-cell mui-media mui-col-xs-0-5">
</li>
<li class="mui-table-view-cell mui-media mui-col-xs-2-5">
<a href="#">
<img class="mui-media-object" src="images/yizhi.jpg">
<div class="mui-media-body">益智</div></a></li>
<li class="mui-table-view-cell mui-media mui-col-xs-0-5">
</li>
<li class="mui-table-view-cell mui-media mui-col-xs-0-5">
</li>
<li class="mui-table-view-cell mui-media mui-col-xs-2-5">
<a href="#">
<img class="mui-media-object" src="images/qinzi.jpg">
<div class="mui-media-body">亲子</div></a></li>
<li class="mui-table-view-cell mui-media mui-col-xs-0-5">
</li>
<li class="mui-table-view-cell mui-media mui-col-xs-0-5">
</li>
<li class="mui-table-view-cell mui-media mui-col-xs-2-5">
<a href="#">
<img class="mui-media-object" src="images/wenyi.jpg">
<div class="mui-media-body">文艺</div></a></li>
<li class="mui-table-view-cell mui-media mui-col-xs-0-5">
</li>
<li class="mui-table-view-cell mui-media mui-col-xs-0-5">
</li>
<li class="mui-table-view-cell mui-media mui-col-xs-2-5">
<a href="#">
<img class="mui-media-object" src="images/tiyu.jpg">
<div class="mui-media-body">体育</div></a></li>
<li class="mui-table-view-cell mui-media mui-col-xs-0-5">
</li>
</ul>
</div>
<!--分类列表结束-->
<!--下拉刷新容器-->
<div id="pullrefresh" class="mui-content mui-scroll-wrapper">
<div class="mui-scroll">
<!--数据列表-->
<ul class="mui-table-view mui-table-view-striped mui-table-view-condensed">
</ul>
</div>
</div>
<!--下拉刷新结束-->
<script src="js/mui.min.js"></script>
<script src="js/app.js"></script>
<script type="text/javascript" charset="utf-8">
mui.init({
swipeBack: false,
pullRefresh: {
container: '#pullrefresh',
up: {
contentrefresh: '正在加载...',
callback: pullupRefresh
}
}
});
var slider = mui("#slider");
slider.slider({
interval: 5000
});
/**
* 上拉加载具体业务实现
*/
var count = 0;
function pullupRefresh() {
setTimeout(function() {
mui('#pullrefresh').pullRefresh().endPullupToRefresh((++count > 2)); //参数为true代表没有更多数据了。
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);
}
}, 1000);
}
if (mui.os.plus) {
mui.plusReady(function() {
setTimeout(function() {
mui('#pullrefresh').pullRefresh().pullupLoading();
}, 500);
});
} else {
mui.ready(function() {
mui('#pullrefresh').pullRefresh().pullupLoading();
});
}
</script>
</body>
</html>
蛤蟆热 (作者)
用一个mui-content还是不行..
2015-03-08 20:25