x-navbottom.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. icon: 'icon-a-xiaoxi',
  39. title: '消息',
  40. }, {
  41. icon: 'icon-wode',
  42. title: '我的',
  43. }],
  44. }
  45. },
  46. mounted() {
  47. },
  48. methods: {
  49. gonavs(e, cindex) {
  50. this.$emit('botomchos', cindex)
  51. }
  52. }
  53. }
  54. </script>
  55. <style lang="scss">
  56. .navmainbox {
  57. position: fixed;
  58. bottom: 0;
  59. left: 0;
  60. z-index: 5;
  61. background-color: #ffffff;
  62. box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
  63. width: 100%;
  64. height: 100rpx;
  65. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  66. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  67. }
  68. .navigation {
  69. z-index: 2024;
  70. position: relative;
  71. display: flex;
  72. justify-content: center;
  73. align-items: center;
  74. height: 100rpx;
  75. padding-bottom: var(--window-bottom);
  76. }
  77. .navigation .navcont {
  78. position: relative;
  79. display: flex;
  80. flex-direction: column;
  81. align-items: center;
  82. flex: 1;
  83. }
  84. .navchosbox {
  85. color: #727289 !important;
  86. margin-top: 2rpx;
  87. font-size: 26rpx;
  88. }
  89. .activeName {
  90. color: #3E80FF !important;
  91. }
  92. .icon_image {
  93. font-size: 44rpx;
  94. }
  95. </style>