IScroll自动计算高度代码

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,再设置自动高度

posted @ 2019-12-07 11:29  zhaogaojian  阅读(491)  评论(0编辑  收藏  举报