x-navbottom.vue 1.8 KB

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