<scroll-view scroll-y   style="height:{{scrollHeight}}px">
       // 计算滚动高度
        var windowHeight = that.data.windowHeight;
        var headerHeight ;
        wx.createSelectorQuery().selectAll('.mine_header').boundingClientRect(function (rects) {
            rects.forEach(function (rect) {
           
                headerHeight= (rect.height)+25;
                console.log(headerHeight)
            })
            that.setData({
                scrollHeight: windowHeight - headerHeight,
              
            })
            console.log('本次高度' + that.data.scrollHeight)
        }).exec()

获取屏幕高度 再减去除了srcoll区域之外的所有容器高度 得出最后的高度 在设置高度内滚动内容如图:

微信小程序,利用wx.createSelectorQuery动态设置swiper或者scroll-view的高度做手机适配

相关文章:

  • 2022-12-23
  • 2021-11-15
  • 2021-08-28
  • 2022-12-23
  • 2021-11-25
  • 2022-12-23
  • 2021-05-05
猜你喜欢
  • 2022-01-07
  • 2022-01-07
  • 2021-06-25
  • 2022-12-23
  • 2022-12-23
  • 2021-10-01
相关资源
相似解决方案