tab-bar.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <view class="tab-bar">
  3. <view class="tab-item" @click="onTabClick(0)">
  4. <uni-icons type="home" size="20" color="#666"></uni-icons>
  5. <text class="tab-text">慢病首页</text>
  6. </view>
  7. <view class="tab-item" @click="onTabClick(1)">
  8. <uni-icons type="bars" size="20" color="#666"></uni-icons>
  9. <text class="tab-text">健康数据</text>
  10. </view>
  11. <view class="tab-item" @click="onTabClick(2)">
  12. <uni-icons type="person" size="20" color="#666"></uni-icons>
  13. <text class="tab-text">个人中心</text>
  14. </view>
  15. </view>
  16. </template>
  17. <script setup lang="ts">
  18. const onTabClick = (index: number) => {
  19. console.log('Tab clicked:', index)
  20. switch (index) {
  21. case 0: // 慢病首页
  22. uni.switchTab({
  23. url: '/pages/index/index'
  24. })
  25. break
  26. case 1: // 健康数据
  27. uni.switchTab({
  28. url: '/pages/health/index'
  29. })
  30. break
  31. case 2: // 个人中心
  32. uni.switchTab({
  33. url: '/pages/profile/index'
  34. })
  35. break
  36. }
  37. }
  38. </script>
  39. <style>
  40. .tab-bar {
  41. position: fixed;
  42. bottom: 0;
  43. left: 0;
  44. right: 0;
  45. height: 100rpx;
  46. background-color: #ffffffe7;
  47. display: flex;
  48. justify-content: space-around;
  49. align-items: center;
  50. border-top: 1rpx solid #eee;
  51. }
  52. .tab-item {
  53. display: flex;
  54. flex-direction: column;
  55. align-items: center;
  56. justify-content: center;
  57. flex: 1;
  58. height: 100%;
  59. }
  60. .tab-text {
  61. font-size: 24rpx;
  62. color: #666;
  63. }
  64. </style>