微信插件scrollView高度 iphone手机高度兼容, 滑动到底部 内容被遮挡问题

微信插件scrollView高度 iphone手机高度兼容, 滑动到底部 内容被遮挡问题,第1张

产品让我改微信插件滑动到底部 内容被遮挡问题
肯定就想到中间一大块用scrollVIew 但是我不知道导航栏和底部tab栏高度
没办法 我只能找方法计算了

我本来准备使用微信小程序的获取元素高度 但是获取结果是null 所有就放弃了

     const res = wx.getSystemInfoSync()
        this.windowWidth = res.windowWidth;
        this.windowHeight = res.windowHeight
        const { top, height } = wx.getMenuButtonBoundingClientRect() // 这个如果报错可以切换一个基础库
        // res.statusBarHeight 这个是顶部 电量那块高度  height 是胶囊高度 top 胶囊到顶部高度
        const navigateHeight = (top - res.statusBarHeight) * 2 + height + res.statusBarHeight // 导航栏高度
        const bottomHeight = res.windowHeight - res.safeArea.bottom // tab下面的高度 有的手机有 tab高度是60 我的是60 可以切换下手机模式能发现这个tab是固定的
        if (bottomHeight == 0) {
            this.scrollHeight =  res.windowHeight - 60 - navigateHeight
        } else {
            this.scrollHeight = res.windowHeight - (bottomHeight + 60) - navigateHeight
            // this.scrollHeight 这个就是中间的滚动高度了
        }

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/996668.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存