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);
			    }
			  }
			});
相关推荐
BUG创建者1 天前
uniapp 开发app时播放实时视频海康ws的流数据
前端·javascript·vue.js·uni-app·html·音视频
CHU7290351 天前
便捷寄件,省心直达——快递寄件小程序前端功能解析
小程序
2501_915918411 天前
网站抓包解析,掌握浏览器请求和 HTTPS 数据分析的流程
android·ios·小程序·https·uni-app·iphone·webview
sheji34161 天前
【开题答辩全过程】以 舞蹈培训管理微信小程序的设计与实现为例,包含答辩的问题和答案
微信小程序·小程序
00后程序员张1 天前
iOS开发者工具有哪些?Xcode、AppUploader(开心上架)、Fastlane如何使用
android·macos·ios·小程序·uni-app·iphone·xcode
焦糖玛奇朵婷1 天前
盲盒抽卡机小程序搭建,探索卡牌市场
大数据·开发语言·程序人生·小程序·软件需求
白菜__1 天前
阿里V2滑块小程序版本
javascript·爬虫·网络协议·小程序·node.js
灵机一物1 天前
灵机一物AI智能电商小程序(已上线)-从“帮我买抽纸”到自动下单支付——大模型驱动全链路自动购物系统实战
人工智能·python·elasticsearch·小程序·fastapi·rag·langgraph
CHU7290351 天前
便捷省心!手机数码租赁小程序前端功能玩法详解
智能手机·小程序