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("");
            $("#" + this.scrollId).height($("#" + this.scrollId).height()+20);
        } else {//无数据
            $("#" + this.scrollId).css("min-height", 0);
            $("#" + this.scrollId).height("");
        }
        if (this.myScroll === undefined || this.myScroll === null) this.loadedsroll();
        else this.myScroll.refresh();
    }

核心为红色部分,最后一句加20

猜你喜欢

转载自www.cnblogs.com/zhaogaojian/p/12001117.html