动态设置scroll-view的高度以及隐藏滚动条

    //获取#header的高度
     var query = wx.createSelectorQuery();
      //选择id
      let that = this;
      query.select('#header').boundingClientRect(function (rect) {
          console.log("获取头部的高度成功");
          that.setData({
              headerHeight:rect.height
          });
      }).exec();

    //获取“可使用窗口”的高度(注意:不包括底下tab栏的高度)
    wx.getSystemInfo({
        success: function (res) {
          that.setData({
            scrollview:res.windowHeight-that.data.headerHeight
          })
        }
      })

wxml

<view style='height:{{scrollview}}px;'></view>

scroll-view滚动条隐藏

wxss

/* scroll-view滚动条隐藏 */
::-webkit-scrollbar{
width: 0;
height: 0;
color: transparent;
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容