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

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

相关推荐
skiyee5 小时前
🚀 用 17 行代码给 UniApp 加上全局登录拦截
前端·uni-app
smartpi_ai7 小时前
JL-17T 能接传感器并把数据发到小程序吗?GPIO/ADC/UART 平台可做,I2C/SPI 要二开
人工智能·小程序·语音识别
andrsted9 小时前
在线刷小程序推荐
学习·微信小程序·小程序·学习方法
Mark108599 小时前
【踩坑】Uni-app微信小程序自定义组件在 Flex 布局中未铺满整行
微信小程序·小程序·uni-app
深瞳智检11 小时前
深瞳智检(小程序)正式上线!【免费/快捷/方便】获取YOLO检测数据集
人工智能·yolo·目标检测·小程序·数据集·cv数据收集
2601_9638702112 小时前
【计算机毕业设计】基于微信小程序的电子家谱的设计与实现
微信小程序·小程序·课程设计
梦曦i13 小时前
create-uni-app v1.1.0:结构化生成,工程骨架更规范
前端·uni-app
zww894911113 小时前
外卖CPS小程序系统:从返利链路到订单回填的技术实现
小程序
lhldsg13 小时前
酒吧点餐小程序开发:从需求分析到技术落地实战
java·前端·小程序·架构·交友
2601_949950631 天前
考研英语资料太散?用小程序把真题、词汇和错题放到一起
人工智能·学习·考研·小程序·刷题·小程序推荐