TabBar.vue 1.3 KB

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