index.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <u-tabbar
  3. v-model="current"
  4. :before-switch="beforeSwitch"
  5. :list="list"
  6. @change="change"
  7. ></u-tabbar>
  8. </template>
  9. <script>
  10. import config from "@/common/config";
  11. export default {
  12. name: "myTabbar",
  13. options: { styleIsolation: "shared" },
  14. data() {
  15. return {
  16. list: [
  17. {
  18. pagePath: "/pages/index/index",
  19. iconPath: config.BASE_IMG_URL + "web/icon/nav1.png",
  20. selectedIconPath: config.BASE_IMG_URL + "web/icon/nav1_on.png",
  21. text: "首页",
  22. },
  23. {
  24. pagePath: "/pages/course/index",
  25. iconPath: config.BASE_IMG_URL + "/web/icon/nav2.png",
  26. selectedIconPath: config.BASE_IMG_URL + "/web/icon/nav2_on.png",
  27. text: "选课",
  28. },
  29. {
  30. pagePath: "/pages/learn/index",
  31. iconPath: config.BASE_IMG_URL + "/web/icon/nav6.png",
  32. selectedIconPath: config.BASE_IMG_URL + "/web/icon/nav6_on.png",
  33. text: "学习",
  34. },
  35. {
  36. pagePath: "/pages/questionBank/index",
  37. iconPath: config.BASE_IMG_URL + "/web/icon/nav3.png",
  38. selectedIconPath: config.BASE_IMG_URL + "/web/icon/nav3_on.png",
  39. text: "题库",
  40. },
  41. {
  42. pagePath: "/pages/information/index",
  43. iconPath: config.BASE_IMG_URL + "/web/icon/nav4.png",
  44. selectedIconPath: config.BASE_IMG_URL + "/web/icon/nav4_on.png",
  45. text: "资料",
  46. },
  47. {
  48. pagePath: "/pages/wd/index",
  49. iconPath: config.BASE_IMG_URL + "/web/icon/nav5.png",
  50. selectedIconPath: config.BASE_IMG_URL + "/web/icon/nav5_on.png",
  51. text: "我的",
  52. },
  53. ],
  54. current: 0,
  55. };
  56. },
  57. mounted() {},
  58. methods: {
  59. beforeSwitch(index) {
  60. return true; // 或者根据逻辑返回false
  61. },
  62. change(index) {
  63. this.current = index;
  64. if (index === 4) {
  65. this.toInformation();
  66. }
  67. },
  68. toInformation() {
  69. uni.reLaunch({
  70. url: "/pages/information/index",
  71. });
  72. },
  73. },
  74. };
  75. </script>
  76. <style lang="scss">
  77. .u-tabbar {
  78. ::v-deep &__content {
  79. z-index: 10000 !important;
  80. }
  81. }
  82. </style>