tabbar.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view>
  3. <view class="bottom_tabbar">
  4. <view v-for="(item,index) in list" :key="index" @tap="changeTabbar(index)">
  5. <image :src="tabbarIndex===index?item.activeImg:item.inactiveImg"></image>
  6. <text :class="tabbarIndex===index?'on':''">{{item.text}}</text>
  7. </view>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. props: {
  14. tabbarIndex: 0
  15. },
  16. data() {
  17. return {
  18. tabbarValue: 0,
  19. list: [{
  20. inactiveImg: './../../static/imgs/tabbar/icon1.png',
  21. activeImg: './../../static/imgs/tabbar/icon1_on.png',
  22. text: '首页',
  23. path: '/pages/index/index'
  24. },
  25. {
  26. inactiveImg: './../../static/imgs/tabbar/icon2.png',
  27. activeImg: './../../static/imgs/tabbar/icon2_on.png',
  28. text: '案例',
  29. path: '/pages/plan/index'
  30. },
  31. {
  32. inactiveImg: './../../static/imgs/tabbar/icon3.png',
  33. activeImg: './../../static/imgs/tabbar/icon3_on.png',
  34. text: '联系我们',
  35. path: '/pages/consult/index'
  36. },
  37. ],
  38. }
  39. },
  40. mounted() {
  41. this.tabbarValue = this.tabbarIndex;
  42. },
  43. methods: {
  44. changeTabbar(e) {
  45. if (!this.list[e].path) return this.$showToast('正在开发中...')
  46. this.tabbarValue = e;
  47. uni.reLaunch({
  48. url: this.list[e].path
  49. })
  50. }
  51. }
  52. }
  53. </script>
  54. <style scoped lang="less">
  55. .bottom_tabbar {
  56. width: 100%;
  57. height: 120rpx;
  58. background: #FFFFFF;
  59. // box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.08);
  60. // border-radius: 60rpx;
  61. display: flex;
  62. align-items: center;
  63. justify-content: space-around;
  64. position: fixed;
  65. left: 0;
  66. bottom: 0;
  67. background-color: #fff;
  68. z-index: 9;
  69. // 底部安全区域
  70. box-sizing: content-box;
  71. padding-bottom: 0 !important;
  72. padding-bottom: constant(safe-area-inset-bottom) !important;
  73. padding-bottom: env(safe-area-inset-bottom) !important;
  74. &>view {
  75. display: flex;
  76. flex-direction: column;
  77. align-items: center;
  78. justify-content: center;
  79. image {
  80. width: 48rpx;
  81. height: 48rpx;
  82. }
  83. text {
  84. margin-top: 8rpx;
  85. font-size: 24rpx;
  86. font-family: PingFangSC, PingFang SC;
  87. font-weight: 500;
  88. color: #666666;
  89. &.on{
  90. color: #385FDF;
  91. font-weight: bold;
  92. }
  93. }
  94. }
  95. }
  96. </style>