IScroll用法
IScroll总体上用起来比较简单,但是如果用不好的可能会产生底部一点滚动不上去的问题。验证可以用的代码如下
整体布局及id如下
searchbar
wrapper
divscroll
window.onload = function () { FillList(); } function FillList() { try { bhttooler.showLoadding("数据正在加载"); if (myScroll == undefined || myScroll == null) loadedsroll(); else myScroll.refresh(); } catch (e) { bhttooler.showToast("cancel", "加载失败" + e); } } var myScroll = null; var wrapperheight = 0; var isMore = false; //是否可刷新标记 var pageIndex = 1; var pageSize = 10; //加载Iscroll function loadedsroll() { setTimeout(function () { myScroll = new IScroll('#wrapper', { click: true }); myScroll.on('scrollStart', function () { document.activeElement.blur(); }); myScroll.on('scrollEnd', function () { var temp_height = 0; temp_height = $("#wrapper").height(); try { var hwindow = (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight)- $('#searchBar').height(); if (temp_height > hwindow) temp_height = hwindow; } catch (e) { } $("#wrapper").height(temp_height); $("#divscroll").css("min-height", temp_height + 1); if (this.y <= this.maxScrollY) { if (isMore == false) { $("#divscroll").height(""); temp_height = $("#divscroll").height(); $("#divscroll").height(temp_height + 30); this.refresh(); return; } pageIndex = pageIndex + 1; FillList(); this.refresh() } else { this.refresh() } }); }, 100); }

更多精彩