x-navbottom.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <!-- 底部tabbar -->
  3. <view class="navmainbox">
  4. <view class="navigation">
  5. <view class="navcont" v-for="(item,index) in list" :key="index" @click="gonavs(item,index)">
  6. <span class="iconfont icon_image" :class="[item.icon,nowchos == index ? 'activeName' :'']"></span>
  7. <view class="navchosbox" :class="nowchos == index ? 'activeName' :''">
  8. {{item.title}}
  9. </view>
  10. </view>
  11. </view>
  12. <!-- //防止 固定的底部菜单遮挡页面上的内容 -->
  13. <view class="navmainbox" style="position: relative;opacity: 0;z-index: 0;">
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. name: 'x-navbottom',
  20. props: {
  21. nowchos: {
  22. type: Number,
  23. default () {
  24. return 0
  25. }
  26. },
  27. },
  28. data() {
  29. return {
  30. dataList: [],
  31. list: [{
  32. icon: 'icon-shouye',
  33. title: '首页',
  34. }, {
  35. icon: 'icon-dingdan',
  36. title: '订单',
  37. },
  38. // {
  39. // icon: 'icon-a-xiaoxi',
  40. // title: '消息',
  41. // },
  42. {
  43. icon: 'icon-wode',
  44. title: '我的',
  45. }
  46. ],
  47. }
  48. },
  49. mounted() {},
  50. methods: {
  51. gonavs(e, cindex) {
  52. this.$emit('botomchos', cindex)
  53. }
  54. }
  55. }
  56. </script>
  57. <style lang="scss">
  58. .navmainbox {
  59. position: fixed;
  60. bottom: 0;
  61. left: 0;
  62. z-index: 5;
  63. background-color: #ffffff;
  64. box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
  65. width: 100%;
  66. height: 100rpx;
  67. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  68. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  69. }
  70. .navigation {
  71. z-index: 2024;
  72. position: relative;
  73. display: flex;
  74. justify-content: center;
  75. align-items: center;
  76. height: 100rpx;
  77. padding-bottom: var(--window-bottom);
  78. }
  79. .navigation .navcont {
  80. position: relative;
  81. display: flex;
  82. flex-direction: column;
  83. align-items: center;
  84. flex: 1;
  85. }
  86. .navchosbox {
  87. color: #727289 !important;
  88. margin-top: 2rpx;
  89. font-size: 26rpx;
  90. }
  91. .activeName {
  92. color: #3E80FF !important;
  93. }
  94. .icon_image {
  95. font-size: 44rpx;
  96. }
  97. </style>