美文网首页
uniapp减去页面某个元素高度,页面剩余部分可滑动

uniapp减去页面某个元素高度,页面剩余部分可滑动

作者: 吃肉肉不吃肉肉 | 来源:发表于2021-09-22 17:52 被阅读0次

效果:


image.png
<view style="height: 180rpx;"></view>
<scroll-view :style="{height: scroll_height}" class="listBox" scroll-y="true"></scroll-view>
data() {
  return {
    scroll_height: 0
  }
}
// 必须放在onReady里
onReady: function(res) {
            var _this = this;
            uni.getSystemInfo({
                success: (resu) => {
                    const query = uni.createSelectorQuery()
                    query.select('.listBox').boundingClientRect()
                    query.exec(function(res) {
                        _this.scroll_height = resu.windowHeight - res[0].top + 'px';
                    })
                },
                fail: (res) => {}
            })
        },

相关文章

网友评论

      本文标题:uniapp减去页面某个元素高度,页面剩余部分可滑动

      本文链接:https://www.haomeiwen.com/subject/wfdggltx.html