index.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view class="myTabbar">
  3. <view class="tabbar"
  4. v-for="(item, index) in list"
  5. :key="index"
  6. @tap="navigatorTo(index, item.url)"
  7. style="text-align:center"
  8. >
  9. <view class="item">
  10. <uni-icons :type="index == activeIndex ? item.activeIconUrl : item.iconUrl" size="26" :color="index == activeIndex ?'#00897B':'#000'" custom-prefix="iconfont"></uni-icons>
  11. </view>
  12. <view :class="index == activeIndex ? 'text-active':'text'">{{item.text}}</view>
  13. </view>
  14. </view>
  15. </template>
  16. <script setup name="MyTabbar">
  17. import { ref } from 'vue'
  18. const activeIndex = ref(0)
  19. const list = ref([
  20. {
  21. activeIconUrl: 'icon-shouye-',
  22. iconUrl: 'icon-shouye',
  23. text: '首页',
  24. url: '/pages/index/index'
  25. },
  26. {
  27. activeIconUrl: 'icon-zhiwei',
  28. iconUrl: 'icon-zhiweisvg',
  29. text: '职位',
  30. url: '/pages/index/position'
  31. },
  32. {
  33. activeIconUrl: 'icon-icon-myself-1',
  34. iconUrl: 'icon-wode',
  35. text: '我的',
  36. url: '/pages/index/my'
  37. }
  38. ])
  39. const navigatorTo = (curIndex, url) => {
  40. activeIndex.value = curIndex
  41. uni.reLaunch({
  42. url
  43. })
  44. }
  45. </script>
  46. <style lang="scss">
  47. .myTabbar {
  48. z-index: 999;
  49. position: fixed;
  50. bottom: 0;
  51. left: 0;
  52. display: flex;
  53. justify-content: space-around;
  54. width: 100%;
  55. height: 100rpx;
  56. background-color: #fff;
  57. border-top: 1px solid #f1f1f1;
  58. .tabbar {
  59. display: flex;
  60. flex-direction: column;
  61. justify-content: space-around;
  62. align-items: center;
  63. width: 20%;
  64. height: 100%;
  65. .item {
  66. width: 50rpx;
  67. height: 50rpx;
  68. text-align: center;
  69. margin-top: 10rpx;
  70. }
  71. .text {
  72. color: #000;
  73. font-size: 22rpx;
  74. }
  75. .text-active{
  76. color: #00897B;
  77. font-size: 22rpx;
  78. }
  79. }
  80. }
  81. </style>