setScrollHeight: function () { var temp_height = 0; temp_height = $("#" + this.wrapperId).height(); try { var showHeight = (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight) - this.headAndBottomHeight; if (temp_height !== showHeight) temp_height = showHeight; } catch (e) { ; }; $("#" + this.wrapperId).height(temp_height); if (!this.isNoData)//有数据 { $("#" + this.scrollId).css("min-height", temp_height + 1); $("#" + this.scrollId).height(""); } else {//无数据 $("#" + this.scrollId).css("min-height", 0); $("#" + this.scrollId).height(""); } if (this.myScroll === undefined || this.myScroll === null) this.loadedsroll(); else this.myScroll.refresh(); }
核心为红色部分,设置最小高度为wrapper高度+1,再设置自动高度
来源:https://www.cnblogs.com/zhaogaojian/p/12001117.html