custom-tabbar-client.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <view class="phone-custom-tabbar">
  3. <view class="tabbar-item" v-for="(item, index) in tabList" :key="index" @click="switchTab(item.path,index)">
  4. <icon class="tabbar-item-icon" :style="{ backgroundImage: 'url(' + (currentTab == index ? item.activePath : item.iconPath) + ')' }"></icon>
  5. <text class="tabbar-item-text">{{item.text}}</text>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. import {getStaticUrl} from '@/utils/common.js';
  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. text: '首页',
  20. path: `/pages/study/index`,
  21. iconPath: getStaticUrl('static/images/tabbar/unselect/index-icon.png'),
  22. activePath: getStaticUrl('static/images/tabbar/select/index-icon.png'),
  23. },
  24. {
  25. text: '我的',
  26. path: `/pages/my/index`,
  27. iconPath: getStaticUrl('static/images/tabbar/unselect/my-icon.png'),
  28. activePath: getStaticUrl('static/images/tabbar/select/my-icon.png'),
  29. },
  30. ],
  31. currentTab: 0,
  32. };
  33. },
  34. methods: {
  35. switchTab(path, index) {
  36. uni.redirectTo({url: path});
  37. /* uni.navigateTo({
  38. url: path,
  39. "animationType": "fade-in",
  40. "animationDuration":0
  41. }); */
  42. },
  43. },
  44. created() {
  45. this.currentTab =this.currentTabNumber
  46. }
  47. }
  48. </script>