当前位置:   article > 正文

UniApp自定义底部导航栏_uniapp 底部导航

uniapp 底部导航

1、首先在components中创建公用组件名为“personBtn”的文件

  1. <template name='personBtn'>
  2. <view>
  3. <view class="fixed">
  4. <view class="fixed_menu">
  5. <navigator url="/pages/index/index" hover-class="none" open-type="redirectTo" :class="is_ShouYe?'c_b6a':'c_e1'">
  6. <view class="iconfont" :class="is_ShouYe?'c_b6a':'c_e1'">
  7. <image src="../static/img/fangzi.png" v-if="is_ShouYe" style="width: 48upx;height: 48upx;"></image>
  8. <image src="../static/img/no_fangzi.png" v-else style="width: 48upx;height: 48upx;"></image>
  9. </view>
  10. <!-- <view class="iconfont iconwocanyude" v-else :class="is_ShouYe?'c_b6a':'c_e1'"></view> -->
  11. <view class="btn_wz">首页</view>
  12. </navigator>
  13. <!-- <navigator url="/pages/CardTicket/CardTicket" hover-class="none" open-type="redirectTo" :class="is_message?'c_b6a':'c_e1'">
  14. <view class="iconfont" :class="is_message?'c_b6a':'c_e1'">
  15. <image src="../static/img/nav2.png" v-if="is_message"></image>
  16. <image src="../static/img/nav2h.png" v-else></image>
  17. </view>
  18. <view class="btn_wz">卡券</view>
  19. </navigator> -->
  20. <navigator url="/pages/my/my" hover-class="none" open-type="redirectTo" :class="is_My?'c_b6a':'c_e1'" style="position: relative;">
  21. <view class="iconfont" :class="is_My?'c_b6a':'c_e1'">
  22. <image src="../static/img/wode.png" v-if="is_My" style="width: 42upx;height: 48upx;"></image>
  23. <image src="../static/img/no_wode.png" v-else style="width: 42upx;height: 48upx;"></image>
  24. <view class="resdian" v-if="redIsShow"></view>
  25. </view>
  26. <view class="btn_wz">我的</view>
  27. </navigator>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. name: 'personBtn',
  35. props: {
  36. is_ShouYe: {
  37. type: Boolean,
  38. default: false
  39. },
  40. is_message:{
  41. type:Boolean,
  42. default:false
  43. },
  44. is_My:{
  45. type:Boolean,
  46. default:false
  47. },
  48. is_follow:{
  49. type: Boolean,
  50. default: false
  51. }
  52. },
  53. onLoad() {
  54. console.log(this.is_ShouYe,'>>>>>>>>>>>>>>>>>>>>')
  55. },
  56. data() {
  57. return {
  58. redIsShow:false
  59. };
  60. },
  61. mounted() {
  62. },
  63. methods: {
  64. },
  65. }
  66. </script>
  67. <style>
  68. .resdian{position: absolute;right: 0;top: 0;width: 10upx;height: 10upx;border-radius: 50%;background: red;}
  69. .fixed {
  70. position: fixed;
  71. height: 120rpx;
  72. left: 0;
  73. right: 0;
  74. bottom: 0;
  75. background: #fff;
  76. z-index: 111;
  77. }
  78. .bank {
  79. width: 120rpx;
  80. text-align: center;
  81. height: 120rpx;
  82. font-size: 20rpx;
  83. position: absolute;
  84. bottom: 0rpx;
  85. left: 0rpx;
  86. line-height: 60rpx;
  87. background: #FF5E6C;
  88. overflow: hidden;
  89. }
  90. .fixed_menu {
  91. height: 120rpx;
  92. width: 100%;
  93. display: flex;
  94. padding: 0 190upx;
  95. box-sizing: border-box;
  96. justify-content: space-between;
  97. align-items: center;
  98. text-align: center;
  99. border-top: 2upx solid rgb(242,242,242);
  100. box-shadow: 0 0 0 0 rgb(242,242,242);
  101. }
  102. .fixed_menu image{
  103. display: block;
  104. width: 52rpx;
  105. height: 44rpx;
  106. margin: 0 auto;
  107. }
  108. /* .fixed_menu navigator {
  109. float: left;
  110. text-align: center;
  111. } */
  112. .bank .iconfont,
  113. .fixed_menu .iconfont {
  114. font-size: 40rpx;
  115. line-height: 50rpx;
  116. line-height: 50rpx;
  117. margin-top: 10rpx;
  118. color: #A6B1C0;
  119. }
  120. .btn_wz {
  121. font-size: 24rpx;
  122. width: 100%;
  123. text-align: center;
  124. height: 50rpx;
  125. line-height: 50rpx;
  126. }
  127. </style>


2、引用方法 
 

  1. import personBtn from '../../components/personBtn.vue';  
  2. components: {
  3.             personBtn
  4.         },
  5. <personBtn :is_ShouYe="true"></personBtn>

3、将pages.json中的 tabBar 全部隐藏或者删除

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