LearnHelper.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <div class="learn_container">
  3. <el-card class="header" style="padding-bottom: 0">
  4. <div class="tab">
  5. <div
  6. class="tab_item pointer"
  7. v-for="item in tabList"
  8. :class="tabActive == item.value ? 'tab_active' : ''"
  9. @click="switchTab(item.value)"
  10. >
  11. {{ item.label }}
  12. </div>
  13. </div>
  14. </el-card>
  15. <!-- 收藏夹 -->
  16. <div class="content">
  17. <collect v-if="tabActive == 0"></collect>
  18. <!-- 错题本 -->
  19. <mistake v-if="tabActive == 1"></mistake>
  20. <!-- 学习记录 -->
  21. <learn-record v-if="tabActive == 2"></learn-record>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. import Collect from './components/collect'
  27. import Mistake from './components/mistake'
  28. import LearnRecord from './components/learn-record'
  29. export default {
  30. components: { Collect, Mistake, LearnRecord },
  31. data() {
  32. return {
  33. tabActive: 0,
  34. tabList: [
  35. {
  36. label: '收藏夹',
  37. value: 0
  38. },
  39. {
  40. label: '错题本',
  41. value: 1
  42. },
  43. {
  44. label: '学习记录',
  45. value: 2
  46. }
  47. ],
  48. }
  49. },
  50. created() {
  51. // 设置默认高亮
  52. this.tabActive = this.$route.query.tabActive
  53. ? this.$route.query.tabActive
  54. : 0
  55. this.switchTab(this.tabActive)
  56. },
  57. methods: {
  58. switchTab(index) {
  59. this.tabActive = index
  60. },
  61. }
  62. }
  63. </script>
  64. <style scoped>
  65. .learn_container {
  66. padding: 20px;
  67. background: #f7f7f7;
  68. min-height: 100vh;
  69. }
  70. .header {
  71. margin-bottom: 16px;
  72. }
  73. .content {
  74. background: #fff;
  75. padding: 20px;
  76. }
  77. .tab {
  78. display: flex;
  79. margin-bottom: 14px;
  80. border-bottom: 1px solid #dedede;
  81. }
  82. .tab .tab_item {
  83. flex: 1;
  84. cursor: pointer;
  85. text-align: center;
  86. font-size: 16px;
  87. font-family: PingFangSC-Medium, PingFang SC;
  88. font-weight: 500;
  89. line-height: 22px;
  90. padding-bottom: 28px;
  91. position: relative;
  92. }
  93. .tab .tab_active {
  94. color: #47c6a2;
  95. }
  96. .tab .tab_active::after {
  97. content: "";
  98. height: 4px;
  99. width: 100%;
  100. background: #47c6a2;
  101. position: absolute;
  102. transform: translateY(50%);
  103. left: 0;
  104. bottom: 0;
  105. }
  106. </style>