uniapp自定义底部导航栏,解决下拉时候顶部空白的问题

一、背景

最近使用uniapp开发微信小程序,因为使用了自定义的顶部导航栏,所以在ios平台上(Android未测试)测试的时候,下拉的时候会出现整个页面下拉并且顶部留下大片空白的问题

二、任务:解决这个问题

经查阅资料,在这个使用自定义导航栏的页面,首先需要设置

javascript 复制代码
		{
			"path" : "pages/test/index",
			"style" : 
			{
				"navigationBarTitleText" : "原生导航栏",
				"navigationStyle":"custom",
				"disableScroll":true
			}
		}

其中 "disableScroll":true是关键,这样设置下来,可以解决问题,但是整个页面都不能滑动,这显然不合理。所以在内容展示区需要用scroll-view 来包裹,高度需要动态设置,也就是整个页面的高度-自定义导航栏的 高度

javascript 复制代码
	  <scroll-view 
	  scroll-y="true" 
	  class="scrollw" 
	  :style="{height:`calc(100% - ${barheight}px)`}"
	  refresher-enabled
	  :refresher-triggered="refreshStatus"
	  refresher-threshold
	  refresher-default-style="white"
	  refresher-background="#4cd964"
	  @scrolltoupper="handleToUpper"
	  @scrolltolower="handleToLower"
	  @refresherrefresh="handlePullDownRefresh">
	  <view class="content" v-for="i in count" :key="i">
	  	<view class="">
	  		顶部 刷新 {{i}}
	  	</view>
		<view class="bootom">
			底部  {{i}}
		</view>
	
	  </view>
	  <view class="loading" v-if="loading">
	  	努力加载中...
	  </view>
	  <view class="loading" v-else>
	  	已经没有更多了
	  </view>
	  </scroll-view>

通过,@refresherrefresh和@scrolltolower可以实现自定义的下拉刷新和触底加载更多的功能

三、自定义导航栏高度

有两种方式:通过公式:自定义导航栏高度 = 状态栏高度 + 胶囊按钮高度 + (胶囊按钮距离顶部 - 状态栏高度) * 2

一、

二、直接用 const {safeAreaInsets} = uni.getWindowInfo() + 44(44是规定的)

自定义导航栏里的内容padding-top = 胶囊按钮距离顶部的距离,这样能使自定义导航栏里的内容始终跟胶囊按钮对齐

相关推荐
2501_915918417 小时前
怎么把 Python 写的 Flet 应用打包成 iOS App 并上架 App Store?
android·ios·小程序·https·uni-app·iphone·webview
Geek_Vison8 小时前
小程序容器如何抹平系统差异,让一个小程序运行在 iOS、安卓、鸿蒙和电脑端
小程序·uni-app·harmonyos·mpaas
PedroQue999 小时前
0.5.0重磅发布:动画插件+H5体验全面优化
前端·uni-app
anyup1 天前
仍然是简单一句话,uView Pro Starter 一键清理 Skill 发布
前端·人工智能·uni-app
00后程序员张1 天前
怎么用 Egret(白鹭引擎)打包 iOS 应用并上架 App Store?
android·ios·小程序·https·uni-app·iphone·webview
xujuzheng1 天前
2026深圳小程序/App/AI智能体开发公司选型指南(附本地服务商盘点)
数据库·科技·微信小程序·小程序·uni-app
郑州光合科技余经理2 天前
本地生活系统:多业务订单字段怎么分账本导出
java·开发语言·前端·数据库·uni-app·php·ai编程
EatFan3 天前
Java接入支付宝 JSAPI 支付保姆教程(二):流程讲解与前后端代码讲解
前端·spring boot·后端·微信小程序·小程序·uni-app
bug总结4 天前
uniapp vue3全局方法注册使用
前端·javascript·uni-app
大佐不会说日语~4 天前
Android 16 下 uni-app APP 提示“网络连接失败”的排障与修复
android·uni-app