uniapp微信小程序无法屏蔽右上角胶囊按钮(...)问题解决方案

从网上查了很多方法,基本都是靠在pages.json中对应页面添加"navigationBarRightButton": {"hide":true}

javascript 复制代码
{
  "navigationBarTitleText": "我的页面",
  "navigationStyle": "custom",
  "navigationBarBackgroundColor": "#0000FF",
  "navigationBarRightButton": {"hide":true}, // 隐藏右侧胶囊按钮
  "usingComponents": {}
}

但是该方法仅限模拟器中生效,在真机下还是在的,所以没法去除或者隐藏胶囊按钮。

综上所述,只能想办法避开它

参考:https://uniapp.dcloud.net.cn/api/ui/menuButton.html#getmenubuttonboundingclientrect

实现效果如下:

代码如下,主要是靠margin-right:

html 复制代码
<!-- 分享图标 -->
<view class="share-icon-box" @tap="handleShare" :style="{marginRight:(statusWidth + searchRight+'px')}">
	<text class="iconfont icon-ic_share1"></text>
</view>
javascript 复制代码
			// #ifdef MP
			const res = uni.getMenuButtonBoundingClientRect()
			const statusHeight = res.top //胶囊距离顶部
			const statusRight = res.right //胶囊右边界坐标
			const jnHeight = res.height //胶囊高度
			this.statusWidth= res.width
			this.searchTop=statusHeight
			this.searchHeight=jnHeight
			this.searchBoxHeight = this.searchTop*2 + jnHeight
			//搜索框宽度计算
			uni.getSystemInfo({
				success:info=>{
					this.searchRight=info.windowWidth-statusRight
				}
			})
			// #endif

哎~~不想写了,小白一名如所写有误望指正,也希望各位大佬有更好的方法发出来让小弟学习一下

相关推荐
CHU72903518 小时前
便捷约玩,沉浸推理:线上剧本杀APP功能版块设计详解
前端·小程序
px不是xp1 天前
微信小程序组件化开发最佳实践
微信小程序·小程序·notepad++
曲江涛1 天前
微信小程序 摄像头 授权同页面丝滑调用
微信小程序
code_Bo1 天前
kiro生成小程序商业案例
前端·微信小程序·小程序·云开发
软希网分享源码1 天前
中英双语言量化交易投资源码/跟单搬砖区块链交易所源码/前端uniapp纯源码+后端
前端·uni-app·区块链·中英双语言量化交易投资源码
小成Coder1 天前
UniApp 如何调用鸿蒙预加载
uni-app·harmonyos·鸿蒙
编程迪1 天前
基于SpringBoot开发的预约停车系统共享停车位小程序app
小程序·停车场小程序·预约停车·错峰出行·共享车位app
云起SAAS1 天前
早晚安打卡签到小程序完整源码 | 三级分销+红包广告+PC后台 | 商业级系统
小程序
职豚求职小程序1 天前
浙商银行笔试题库小程序练习2026新版题库
小程序
Kingexpand_com1 天前
旅游小程序选型指南:模板与定制开发全解析
小程序·旅游·软件开发·小程序开发·旅游小程序·旅行·定制开发