item.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. <i class="el-icon-close" @click.stop="closeTab" v-if="!menu.meta.hideClose" alt="关闭当前标签页"></i>
  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. display: inline-block;
  44. position: relative;
  45. cursor: pointer;
  46. height: 24px;
  47. line-height: 26px;
  48. border: 1px solid var(--system-header-border-color);
  49. color: var(--system-header-text-color);
  50. background: var(--system-header-tab-background);
  51. padding: 0 8px;
  52. font-size: 12px;
  53. margin-left: 5px;
  54. margin-top: 4px;
  55. border-radius: 2px;
  56. a {
  57. color: var(--system-header-text-color);
  58. height: 26px;
  59. display: inline-block;
  60. padding-left: 8px;
  61. padding-right: 8px;
  62. }
  63. .el-icon-refresh-right {
  64. display: inline-block;
  65. margin-right: 5px;
  66. }
  67. .el-icon-close {
  68. display: inline-block;
  69. height: 26px;
  70. }
  71. &:first-of-type {
  72. margin-left: 15px;
  73. }
  74. &:last-of-type {
  75. margin-right: 15px;
  76. }
  77. &.active {
  78. background: var(--system-primary-color);
  79. border-color: var(--system-primary-color);
  80. color: var(--system-primary-text-color);
  81. a {
  82. color: var(--system-primary-text-color);
  83. }
  84. &:hover {
  85. background: var(--system-primary-color);
  86. }
  87. }
  88. &:hover {
  89. background-color: var(--system-header-item-hover-color);
  90. }
  91. }
  92. </style>