HomeIndex.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <div class="index">
  3. <router-view />
  4. <div class="footer-tabbar">
  5. <div
  6. class="tabbar-item"
  7. v-for="(item, index) in tabbarList"
  8. :key="index"
  9. @click="tabbarChange(item.key)">
  10. <img
  11. class="item-image"
  12. :src="current === item.key ? item.selectedImage : item.image"
  13. alt="" />
  14. <div class="item-text" :class="{ activeClass: current === item.key }">
  15. {{ item.text }}
  16. </div>
  17. </div>
  18. </div>
  19. </div>
  20. </template>
  21. <script setup>
  22. import { useRouter } from "vue-router";
  23. import { ref } from "vue";
  24. const router = useRouter();
  25. const current = ref("index");
  26. const tabbarChange = (key, path) => {
  27. current.value = key;
  28. router.push('/'+key);
  29. };
  30. const tabbarList = [
  31. {
  32. key: "index",
  33. path: "/",
  34. image: require("@/assets/icon/tabbar/home-clicked.png"),
  35. selectedImage: require("@/assets/icon/tabbar/home-clicked.png"),
  36. text: "首页",
  37. },
  38. {
  39. key: "market",
  40. path: "/marketIndex",
  41. image: require("@/assets/icon/tabbar/bitcoin-circle.png"),
  42. selectedImage: require("@/assets/icon/tabbar/bitcoin-circle.png"),
  43. text: "行情",
  44. },
  45. {
  46. key: "bitcoin",
  47. path: "/bitcoin",
  48. image: require("@/assets/icon/tabbar/bitcoin-circle.png"),
  49. selectedImage: require("@/assets/icon/tabbar/bitcoin-circle.png"),
  50. text: "交易",
  51. },
  52. {
  53. key: "asset",
  54. path: "/assetIndex",
  55. image: require("@/assets/icon/tabbar/wallet.png"),
  56. selectedImage: require("@/assets/icon/tabbar/wallet.png"),
  57. text: "资产",
  58. },
  59. {
  60. key: "user",
  61. image: require("@/assets/icon/tabbar/user-circle.png"),
  62. selectedImage: require("@/assets/icon/tabbar/user-circle.png"),
  63. text: "我的",
  64. },
  65. ];
  66. </script>
  67. <style lang="less" scoped>
  68. .index {
  69. width: 100%;
  70. .footer-tabbar {
  71. position: fixed;
  72. left: 0;
  73. bottom: 0;
  74. z-index: 99;
  75. display: flex;
  76. justify-content: space-around;
  77. align-items: center;
  78. width: 100%;
  79. height: 60px;
  80. background: #fff;
  81. .tabbar-item {
  82. display: flex;
  83. flex-direction: column;
  84. align-items: center;
  85. justify-content: center;
  86. flex: 1;
  87. .item-image {
  88. margin-bottom: 6px;
  89. width: 19px;
  90. height: 19px;
  91. }
  92. .item-text {
  93. font-family: "PingFang SC";
  94. font-style: normal;
  95. font-weight: 400;
  96. font-size: 12px;
  97. color: #a8a8a8;
  98. &.activeClass {
  99. font-family: "PingFang SC";
  100. font-style: normal;
  101. font-weight: 400;
  102. font-size: 12px;
  103. color: #df384c;
  104. }
  105. }
  106. }
  107. }
  108. }
  109. </style>