uni.getSystemInfo({
success: (res) => {
// 需要使用箭头函数,swiper 高度才能设置成功
// 获取swiperHeight可以获取的高度,窗口高度减去导航栏高度
this.swiperHeight = res.windowHeight - uni.upx2px(84) - this.CustomBar
}
});
<!-- <swiper :style="[{height:swiperHeight + 'px'}]" style="background-color: aqua;" :current="current"
@animationfinish="swiperAnimationfinish">
<swiper-item v-for="(item, index) in tabList" :key="index">
{{item}}
</swiper-item>
</swiper> -->
获取页面的区域可视高度
最新推荐文章于 2024-05-04 14:55:11 发布
该博客介绍了如何在uni-app中使用uni.getSystemInfo接口获取设备窗口高度,并结合自定义导航栏高度计算swiper组件的高度,确保内容正确显示。文章通过示例代码展示了动态设置swiper高度的方法。
摘要由CSDN通过智能技术生成