custom-tabbar-client.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <view class="ezy-custom-tabbar">
  3. <view class="tabbar-item-box">
  4. <view class="tabbar-item" v-for="(item, index) in tabList" :key="index" @click="switchTab(item.path,index)"
  5. :style="{ backgroundImage: 'url(' + (currentTab == index ? item.activePath : item.iconPath) + ')' }">
  6. </view>
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. import {
  12. useTabBarHistory
  13. } from '@/utils/emitEvents.js';
  14. import cacheManager from "@/utils/cacheManager.js";
  15. export default {
  16. data() {
  17. return {
  18. tabList: [{
  19. iconPath: 'static/images/tabbar/unselect/plan-sj.png',
  20. activePath: 'static/images/tabbar/select/plan-sj.png',
  21. path: `/pages/study/index`
  22. },
  23. {
  24. iconPath: 'static/images/tabbar/unselect/partner-sj.png',
  25. activePath: 'static/images/tabbar/select/partner-sj.png',
  26. path: '/pages/game/index'
  27. },
  28. {
  29. iconPath: 'static/images/tabbar/unselect/my-sj.png',
  30. activePath: 'static/images/tabbar/select/my-sj.png',
  31. path: `/pages/my/index`
  32. },
  33. ],
  34. currentTab: 0,
  35. };
  36. },
  37. methods: {
  38. switchTab(path, index) {
  39. uni.redirectTo({url: path});
  40. /* uni.navigateTo({
  41. url: path,
  42. "animationType": "fade-in",
  43. "animationDuration":0
  44. }); */
  45. },
  46. },
  47. created() {
  48. this.currentTab =this.currentTabNumber
  49. }
  50. }
  51. </script>
  52. <style scoped>
  53. .custom-tabbar {
  54. display: flex;
  55. justify-content: space-around;
  56. align-items: center;
  57. /* 其他样式 */
  58. }
  59. .tab-item {
  60. flex: 1;
  61. /* 样式 */
  62. }
  63. .tab-icon {
  64. /* 图标样式 */
  65. }
  66. </style>