index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <div class="thirdMenu">
  3. <a-tabs v-model:activeKey="current" @change="menuClick">
  4. <a-tab-pane :key="String(index)" v-for="(item, index) in list" :tab="item[value]"></a-tab-pane>
  5. </a-tabs>
  6. <slot></slot>
  7. </div>
  8. </template>
  9. <script lang="ts">
  10. import { defineComponent, ref, PropType } from 'vue';
  11. interface Key {
  12. [propName: string]: string;
  13. }
  14. export default defineComponent({
  15. name: 'third-menu',
  16. emits: ['selectMenu'],
  17. props: {
  18. list: {
  19. default: [],
  20. type: Object as PropType<Key[]>,
  21. },
  22. value: {
  23. // 需要绑定的值得 key
  24. default: 'lable',
  25. type: String,
  26. },
  27. selectedKey: {
  28. default: '0',
  29. type: String,
  30. },
  31. },
  32. components: {},
  33. setup(props, context) {
  34. const current = ref<string>(props.selectedKey.toString());
  35. function menuClick(value: string) {
  36. const index = +value;
  37. const item = props.list[index];
  38. context.emit('selectMenu', +value, item);
  39. }
  40. return {
  41. current,
  42. menuClick,
  43. };
  44. },
  45. });
  46. </script>
  47. <style lang="less">
  48. .noBorderBottom {
  49. border-bottom: none;
  50. }
  51. .thirdMenu {
  52. display: flex;
  53. justify-content: space-between;
  54. align-items: center;
  55. width: 100%;
  56. padding-top: 2px;
  57. background-color: @m-black5;
  58. z-index: 2;
  59. margin-top: auto;
  60. .ant-tabs {
  61. .flex;
  62. .ant-tabs-bar {
  63. margin-bottom: 0;
  64. border-bottom: 0;
  65. .ant-tabs-nav-container {
  66. margin-bottom: 0;
  67. .ant-tabs-nav-wrap {
  68. margin-bottom: 0;
  69. .ant-tabs-nav-scroll {
  70. .ant-tabs-nav {
  71. .ant-tabs-tab {
  72. min-width: 121px;
  73. height: 26px;
  74. line-height: 26px;
  75. text-align: center;
  76. color: @m-grey1;
  77. padding: 0 20px;
  78. margin: 0;
  79. background: @m-tabbg center center no-repeat;
  80. background-size: cover;
  81. }
  82. .ant-tabs-tab-active.ant-tabs-tab {
  83. color: @m-white0;
  84. background: @m-tabbg-active center center no-repeat;
  85. background-size: cover;
  86. z-index: 2;
  87. }
  88. .ant-tabs-tab + .ant-tabs-tab {
  89. margin-left: -14px;
  90. }
  91. .ant-tabs-ink-bar {
  92. width: 0px !important;
  93. }
  94. }
  95. }
  96. }
  97. }
  98. }
  99. }
  100. }
  101. </style>