uni-app 微信小程序自定义导航栏

一、效果图

二、导航栏的组成

上面的导航栏主要由状态栏(就是手机电量显示栏)和小程序的导航栏组成,android手机一般为48px,ios手机一般为44px

三、开发步骤

1、设置navigationStyle:custom

bash 复制代码
{
			"path": "pages/views/home/detail",
			"style": {
				"navigationStyle": "custom" ,// 隐藏系统导航栏
				"navigationBarTitleText": "车况"
			}
		},

2、页面导航栏div

bash 复制代码
<!-- 手机状态栏高度 -->
<view :style="'height:'+statusBarHeight+'px'" class="wper100"></view>
<!-- 微信导航栏高度-->
<view :style="'height:'+navTitleHeight+'px'" class="wper100">

3、获取statusBarHeight高度

bash 复制代码
let statusBarHeight = uni.getSystemInfoSync().statusBarHeight;

4、获取navTitleHeight的高度

bash 复制代码
uni.getSystemInfo({
			  success: function(res) {
			    console.log(res.system); // 输出操作系统名称,如 iOS 14.5.1 或 Android 10.0.0
			    // 判断手机是 iOS 还是 Android
			    if (res.system.indexOf('iOS') !== -1) {
			      console.log('手机是 iOS');
				  that.$store.commit("setNavTitleHeight",44);
			      // 在这里执行 iOS 相关的逻辑
			    } else if (res.system.indexOf('Android') !== -1) {
			      console.log('手机是 Android');
			      // 在这里执行 Android 相关的逻辑
				   that.$store.commit("setNavTitleHeight",48);
			    } else {
			      console.log('无法确定手机系统');
				   that.$store.commit("setNavTitleHeight",48);
			    }
			  }
			});
相关推荐
2501_9159214316 小时前
iOS App 电耗管理 通过系统电池记录、Xcode Instruments 与克魔(KeyMob)组合使用
android·ios·小程序·https·uni-app·iphone·webview
数字游民952718 小时前
2小时VibeCoding了一个看图猜词小程序:猜对了么
人工智能·ai·小程序·ai绘画·数字游民9527
qq_12498707531 天前
基于小程序中医食谱推荐系统的设计(源码+论文+部署+安装)
java·spring boot·后端·微信小程序·小程序·毕业设计·计算机毕业设计
2501_915918411 天前
iOS App 测试方法,Xcode、TestFlight与克魔(KeyMob)等工具组合使用
android·macos·ios·小程序·uni-app·iphone·xcode
棒棒的唐1 天前
微信小程序右上角分享按钮如何根据用户登录状态确定是否允许分享
微信小程序·小程序
2501_915921431 天前
iOS 描述文件制作过程,从 Bundle ID、证书、设备到描述文件生成后的验证
android·ios·小程序·https·uni-app·iphone·webview
小白学大数据1 天前
基于 Python 的知网文献批量采集与可视化分析
开发语言·爬虫·python·小程序
毕设源码-郭学长1 天前
【开题答辩全过程】以 基于微信小程序的医院管理系统为例,包含答辩的问题和答案
微信小程序·小程序
毕设源码-朱学姐1 天前
【开题答辩全过程】以 基于微信小程序的医疗物资进销存管理为例,包含答辩的问题和答案
微信小程序·小程序
低代码布道师1 天前
教培管家第06讲:搭建销售工作台——公海争夺与私海管理
低代码·小程序·云开发