uniapp动态显隐导航栏图标

uniapp动态显隐导航栏图标

实现思路: 将图标的宽度设置为0,就可以将图标隐藏
上代码:

var pageView= this.$mp.page.$getAppWebview();  
if("隐藏条件触发") { // 隐藏
	pageView.setTitleNViewButtonStyle(0,{  
   		width: '0'  
	});  
	pageView.setTitleNViewButtonStyle(1,{  
    	width: '0'  
	});
} else { // 显示  
	pageView.setTitleNViewButtonStyle(0,{  
   		width: '100' // 具体数值根据图标大小调整
	});  
	pageView.setTitleNViewButtonStyle(1,{  
    	width: '100' // 具体数值根据图标大小调整
	});
}

OK,解决~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用\[1\]:根据提供的引用内容,当自定义的 tabbar 在点击tab进行跳转时,custom-tab-bar组件也会刷新页面,所以需要连续点击两次icon才会变为选中状态。为了解决这个问题,可以在每个tab页的onShow方法中定义选中的方法。具体的解决方法如下:如果(typeof this.$mp.page.getTabBar === 'function' && this.$mp.page.getTabBar()) { this.$mp.page.getTabBar().setData({ selected: 0 }) }。\[1\] 引用\[2\]:根据提供的引用内容,可以通过以下方式引入custom-tab-bar文件夹下的index.json:{ "component": true, "usingComponents": { "van-tabbar": "@vant/weapp/tabbar/index", "van-tabbar-item": "@vant/weapp/tabbar-item/index" } }。\[2\] 引用\[3\]:根据提供的引用内容,问题是在组件里面明明正确地定义了methods属性,也定义了init方法,但是页面调用该方法时会报错:this.getTabbar(...).init is not a function。根据提供的代码,可以看出在methods属性中确实定义了init方法。然而,报错的原因可能是因为在页面中调用该方法时,使用了this.getTabbar(),而实际上应该使用this.getTabBar()。所以正确的调用方法应该是this.getTabBar().init()。\[3\] 综上所述,根据提供的引用内容,可以解决问题this.getTabBar is not a function,需要将调用方法改为this.getTabBar().init()。 #### 引用[.reference_title] - *1* [uniapp编译小程序,小程序中this.getTabBar()输出为undefined](https://blog.csdn.net/weixin_41847305/article/details/125448540)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [微信小程序+VantWeapp自定义tabBar,解决 this.gettabbar is not a function。](https://blog.csdn.net/weixin_52421164/article/details/130848796)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [微信小程序自定义tabbar无法调用methods](https://blog.csdn.net/qq_43995263/article/details/129027845)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值