item.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div class="tags-view-item" :class="active ? 'active' : ''">
  3. <router-link :to="menu.path" v-if="menu.meta.title">
  4. {{ menu.meta.title }}
  5. </router-link>
  6. <el-icon><Close @click.stop="closeTab" v-if="!menu.meta.hideClose" title="关闭当前标签页"></Close></el-icon>
  7. </div>
  8. </template>
  9. <script>
  10. import { defineComponent } from 'vue'
  11. export default defineComponent({
  12. props: {
  13. menu: {
  14. type: Object,
  15. default: () => {
  16. return {
  17. path: '',
  18. meta: {
  19. label: '',
  20. hideClose: false,
  21. },
  22. }
  23. },
  24. },
  25. active: {
  26. type: Boolean,
  27. default: false,
  28. },
  29. },
  30. setup(props, { emit }) {
  31. // 关闭按钮
  32. function closeTab() {
  33. emit('close')
  34. }
  35. return {
  36. closeTab,
  37. }
  38. },
  39. })
  40. </script>
  41. <style lang="scss" scoped>
  42. .tags-view-item {
  43. flex-shrink: 0;
  44. display: flex;
  45. align-items: center;
  46. justify-content: center;
  47. text-align: center;
  48. cursor: pointer;
  49. height: 24px;
  50. line-height: 24px;
  51. border: 1px solid var(--system-header-border-color);
  52. color: var(--system-header-text-color);
  53. background: var(--system-header-tab-background);
  54. padding: 0 8px;
  55. font-size: 12px;
  56. margin-left: 5px;
  57. margin-top: 4px;
  58. border-radius: 2px;
  59. a {
  60. color: var(--system-header-text-color);
  61. height: 24px;
  62. display: inline-block;
  63. padding-left: 8px;
  64. padding-right: 8px;
  65. }
  66. .el-icon-refresh-right {
  67. display: inline-block;
  68. margin-right: 5px;
  69. }
  70. .el-icon-close {
  71. display: inline-block;
  72. height: 24px;
  73. }
  74. &:first-of-type {
  75. margin-left: 15px;
  76. }
  77. &:last-of-type {
  78. margin-right: 15px;
  79. }
  80. &.active {
  81. background: var(--system-primary-color);
  82. border-color: var(--system-primary-color);
  83. color: var(--system-primary-text-color);
  84. a {
  85. color: var(--system-primary-text-color);
  86. }
  87. &:hover {
  88. background: var(--system-primary-color);
  89. }
  90. }
  91. &:hover {
  92. background-color: var(--system-header-item-hover-color);
  93. }
  94. }
  95. </style>