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

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

相关推荐
小码哥0683 小时前
从三甲综合医院到连锁诊所:医院管理小程序的场景化突围逻辑(陪诊系统-陪诊APP-陪诊小程序)
小程序·医院管理系统·陪诊小程序·陪诊系统·陪诊app
2501_916007474 小时前
iOS和macOS应用程序性能分析和优化工具使用综合指南
android·macos·ios·小程序·uni-app·iphone·webview
正在走向自律5 小时前
用豆包Seed Evolving打造全功能【AI智能记账】小程序,开源可落地
人工智能·小程序·开源·智能记账
小羊Yveesss1 天前
模板建站哪个平台好?模板数量之外还要比较编辑与SEO能力
大数据·人工智能·小程序
2501_916007471 天前
深入理解HTTPS对称与非对称加密机制及Charles抓包实践
网络协议·http·ios·小程序·https·uni-app·iphone
郑州光合科技余经理1 天前
家政O2O平台解析:从0搭建上门预约小程序解决方案
android·java·开发语言·前端·小程序·架构·php
小徐_23331 天前
AI 写 wot-ui 总在猜 API?我们把 Skills、MCP 和 CLI 都配好了
前端·uni-app·ai编程
维双云1 天前
小程序商城制作一个需要多少钱?2026报价明细与成本拆解
小程序
Liu.7741 天前
uni-app 组件 uni-easyinput 常见 Bug 及解决方案
uni-app·bug
郑州光合科技余经理1 天前
家政预约小程序后端源码深度剖析:支付回调实战
java·开发语言·前端·git·小程序·架构·php