当前位置:   article > 正文

uniapp真机调试app动态显示隐藏tabbar某一项_uniapp 底部导航栏动态显示隐藏某个

uniapp 底部导航栏动态显示隐藏某个

1.pages.json中设置需要显示隐藏项的visible属性, 以list中index:2为例

  1. "tabBar": {
  2. "color": "#9FA8BB",
  3. "selectedColor": "#3E71FE",
  4. "backgroundColor": "#FFFFFF",
  5. "borderStyle": "white",
  6. "fontSize": "10px",
  7. "iconWidth": "23px",
  8. "spacing": "6.5px",
  9. "height": "50px",
  10. "list": [
  11. {
  12. "pagePath": "view/xxx/xxx",
  13. "iconPath": "static/img/index/home.png",
  14. "selectedIconPath": "static/img/index/home-active.png",
  15. "text": "xxx"
  16. },
  17. {
  18. "pagePath": "view/xxx/xxx",
  19. "iconPath": "static/img/index/data.png",
  20. "selectedIconPath": "static/img/index/data-active.png",
  21. "text": "xxx"
  22. },
  23. // #ifdef APP-PLUS
  24. {
  25. "pagePath": "view/xxx/xxx",
  26. "iconPath": "static/img/index/yewuban-kqdk-daka.png",
  27. "selectedIconPath": "static/img/index/yewuban-kqdk-daka-active.png",
  28. "text": "xxx",
  29. "visible": false
  30. },
  31. // #endif
  32. {
  33. "pagePath": "view/xxx/xxx",
  34. "iconPath": "static/img/index/my.png",
  35. "selectedIconPath": "static/img/index/my-active.png",
  36. "text": "xxx"
  37. }
  38. ]
  39. },

2.uni.setTabBarItem 根据项目角色的权限,动态显示隐藏该项

  1. if(xxxxxx){
  2. console.log('添加tab');
  3. uni.setTabBarItem({
  4. index: 2,
  5. visible: true
  6. });
  7. }else{
  8. console.log('隐藏tab');
  9. uni.setTabBarItem({
  10. index: 2,
  11. visible: false
  12. });
  13. }

3.测试app有效,微信开发者工具模拟器上没有效果

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/605060
推荐阅读
相关标签
  

闽ICP备14008679号