1、主要计算滚动组件的高度,避免屏幕出现滚动条,需求如下

在这里插入图片描述

  <scroll-view :scroll-top="scrollTop"  :style="{ height: scrollHeight}"
scroll-y="true" enable-back-to-top >
          <slot></slot>
  </scroll-view>


<script>
// windowHeight :不包含NavigationBar和TabBar的高度
	var statusBarHeight = uni.getSystemInfoSync().statusBarHeight
	var height = null
	// 获取可视区域的高度
	uni.getSystemInfo({
		success: res => {
			// 因为获取的高度是px,设置的是upx ,需要转换
			height= (res.windowHeight + statusBarHeight - uni.upx2px(420)) +'px'
		}
	});
export default {
    data() {
        return {
			scrollTop:0,
			scrollHeight:height
  
        };
    },
</script>
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐